Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/228284
Change subject: Rename OccupationListener to TopicPageCreationListener
......................................................................
Rename OccupationListener to TopicPageCreationListener
This used to be used to create `page` & `revision` etc records
for new boards. Nowadays, however, that functionality is done
elsewhere, before we store the rest of the content (so we can
store the workflow with the associated page_id)
Nowadays, this listener is only used to create the Topic:Xyz
page for posts. We still need to do that to make sure that
core functionality like Title::exists works for Topic:Xyz
pages.
I've also removed the DeletedContributions hook's isEnabled
stuff. Now that we no longer "occupy" on load and occupy what
we used to, this no longer makes sense.
Bug: T105574
Change-Id: I460b3a835eaa74df76340d36fe350d272b92b4e3
---
M Hooks.php
M autoload.php
M container.php
M includes/Api/ApiFlow.php
M includes/Block/TopicList.php
R includes/Data/Listener/TopicPageCreationListener.php
M includes/TalkpageManager.php
7 files changed, 9 insertions(+), 37 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/84/228284/1
diff --git a/Hooks.php b/Hooks.php
index 4e8f324..68aaeb3 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -796,15 +796,9 @@
public static function onDeletedContributionsQuery( &$data, $pager,
$offset, $limit, $descending ) {
set_error_handler( new Flow\RecoverableErrorHandler, -1 );
try {
- // Contributions may be on pages outside the set of
currently
- // enabled pages so we must disable to occupation
listener
- /** @var Flow\Data\Listener\OccupationListener
$listener */
- $listener = Container::get( 'listener.occupation' );
- $listener->setEnabled( false );
/** @var Flow\Formatter\ContributionsQuery $query */
$query = Container::get( 'query.contributions' );
$results = $query->getResults( $pager, $offset, $limit,
$descending );
- $listener->setEnabled( true );
} catch ( Exception $e ) {
wfDebugLog( 'Flow', __METHOD__ . ': Failed
contributions query' );
MWExceptionHandler::logException( $e );
diff --git a/autoload.php b/autoload.php
index 4b8954c..f212c58 100644
--- a/autoload.php
+++ b/autoload.php
@@ -73,9 +73,9 @@
'Flow\\Data\\Listener\\ImmediateWatchTopicListener' => __DIR__ .
'/includes/Data/Listener/WatchTopicListener.php',
'Flow\\Data\\Listener\\ModerationLoggingListener' => __DIR__ .
'/includes/Data/Listener/ModerationLoggingListener.php',
'Flow\\Data\\Listener\\NotificationListener' => __DIR__ .
'/includes/Data/Listener/NotificationListener.php',
- 'Flow\\Data\\Listener\\OccupationListener' => __DIR__ .
'/includes/Data/Listener/OccupationListener.php',
'Flow\\Data\\Listener\\RecentChangesListener' => __DIR__ .
'/includes/Data/Listener/RecentChangesListener.php',
'Flow\\Data\\Listener\\ReferenceRecorder' => __DIR__ .
'/includes/Data/Listener/ReferenceRecorder.php',
+ 'Flow\\Data\\Listener\\TopicPageCreationListener' => __DIR__ .
'/includes/Data/Listener/TopicPageCreationListener.php',
'Flow\\Data\\Listener\\UserNameListener' => __DIR__ .
'/includes/Data/Listener/UserNameListener.php',
'Flow\\Data\\Listener\\WorkflowTopicListListener' => __DIR__ .
'/includes/Data/Listener/WorkflowTopicListListener.php',
'Flow\\Data\\ManagerGroup' => __DIR__ .
'/includes/Data/ManagerGroup.php',
diff --git a/container.php b/container.php
index 72ad069..d4832df 100644
--- a/container.php
+++ b/container.php
@@ -240,7 +240,7 @@
$c['listener.occupation'] = function( $c ) {
global $wgFlowDefaultWorkflow;
- return new Flow\Data\Listener\OccupationListener(
+ return new Flow\Data\Listener\TopicPageCreationListener(
$c['occupation_controller'],
$c['deferred_queue'],
$wgFlowDefaultWorkflow
diff --git a/includes/Api/ApiFlow.php b/includes/Api/ApiFlow.php
index 7675639..d901d7d 100644
--- a/includes/Api/ApiFlow.php
+++ b/includes/Api/ApiFlow.php
@@ -118,9 +118,9 @@
/** @var \Flow\TalkpageManager $controller */
$controller = Container::get( 'occupation_controller' );
if ( $page->getContentModel() !== CONTENT_MODEL_FLOW_BOARD ) {
- // just check for permissions, nothing else to do. if
the commit
- // is successful the OccupationListener will see the
new revision
- // and put the flow board in place.
+ // just check for permissions, nothing else to do. the
flow board
+ // in place right before the rest of the data is
stored, after
+ // everything's been validated.
$status = $controller->allowCreation( $page,
$this->getUser() );
if ( !$status->isGood() ) {
$this->dieUsage( "Page provided does not have
Flow enabled and allowCreation failed with: " . $status->getMessage()->parse(),
'invalid-page' );
diff --git a/includes/Block/TopicList.php b/includes/Block/TopicList.php
index e9f51aa..ffdcd70 100644
--- a/includes/Block/TopicList.php
+++ b/includes/Block/TopicList.php
@@ -160,7 +160,7 @@
/*
* Order of storage is important! We've been changing when we
stored
* workflow a couple of times. For now, it needs to be stored
first:
- * * OccupationListener.php (workflow listener) must first
create the
+ * * TopicPageCreationListener.php (post listener) must first
create the
* Topic:Xyz page before NotificationListener.php (topic/post
* listeners) creates notifications (& mails) that link to it
* * ReferenceExtractor.php (run from ReferenceRecorder.php, a
post
diff --git a/includes/Data/Listener/OccupationListener.php
b/includes/Data/Listener/TopicPageCreationListener.php
similarity index 68%
rename from includes/Data/Listener/OccupationListener.php
rename to includes/Data/Listener/TopicPageCreationListener.php
index 8e6a4bc..c86c0ce 100644
--- a/includes/Data/Listener/OccupationListener.php
+++ b/includes/Data/Listener/TopicPageCreationListener.php
@@ -7,11 +7,7 @@
use Flow\OccupationController;
use SplQueue;
-/**
- * Ensures that a given workflow is occupied. This will be unnecssary
- * once we deprecate the OccupationController white list.
- */
-class OccupationListener extends AbstractListener {
+class TopicPageCreationListener extends AbstractListener {
/** @var OccupationController **/
protected $occupationController;
@@ -21,11 +17,8 @@
/** @var string **/
protected $defaultType;
- /** @var bool **/
- protected $enabled = true;
-
/**
- * @param OccupationController $occupationController The
OccupationController to occupy the page with.
+ * @param OccupationController $occupationController The
OccupationController to create the page with.
* @param SplQueue $deferredQueue Queue of callbacks
to run only if commit succeeds
* @param string $defaultType The workflow type
to look for
*/
@@ -39,26 +32,12 @@
$this->defaultType = $defaultType;
}
- /**
- * Disabling the listener is required if you want to load contributions
- * or other flow history from pages that were enabled but are not
anymore.
- *
- * @param bool $enabled
- */
- public function setEnabled( $enabled ) {
- $this->enabled = (bool)$enabled;
- }
-
public function onAfterLoad( $object, array $old ) {
// Nothing
}
public function onAfterInsert( $object, array $new, array $metadata ) {
if ( !$object instanceof Workflow ) {
- return;
- }
-
- if ( !$this->enabled ) {
return;
}
diff --git a/includes/TalkpageManager.php b/includes/TalkpageManager.php
index 286e54d..709f996 100644
--- a/includes/TalkpageManager.php
+++ b/includes/TalkpageManager.php
@@ -64,8 +64,7 @@
*
* This method does not do any security checks regarding content model
changes
* or the like. Those happen much earlier in the request and should be
checked
- * before even attempting to create revisions which, when written to
the database,
- * trigger this method through the OccupationListener.
+ * before even attempting to create revisions.
*
* @param \Article $article
* @param Workflow $workflow
--
To view, visit https://gerrit.wikimedia.org/r/228284
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I460b3a835eaa74df76340d36fe350d272b92b4e3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits