Catrope has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/259957

Change subject: Revert "Include Flow topics in Nuke"
......................................................................

Revert "Include Flow topics in Nuke"

Breaks on the cluster because of database join issues.

This reverts commit 0c70f5291a82838ae4b0f53148a046fe884d955e.

Change-Id: I568c1a015de79f4d8b98805999f13d6053f82a5c
---
M Flow.php
M Hooks.php
2 files changed, 0 insertions(+), 170 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/57/259957/1

diff --git a/Flow.php b/Flow.php
index 8c0308c..000d7be 100644
--- a/Flow.php
+++ b/Flow.php
@@ -173,10 +173,6 @@
 $wgHooks['GetBetaFeaturePreferences'][] = 
'FlowHooks::onGetBetaFeaturePreferences';
 $wgHooks['UserSaveOptions'][] = 'FlowHooks::onUserSaveOptions';
 
-// Nuke
-$wgHooks['NukeGetNewPages'][] = 'FlowHooks::onNukeGetNewPages';
-$wgHooks['NukeDeletePage'][] = 'FlowHooks::onNukeDeletePage';
-
 // Extension initialization
 $wgExtensionFunctions[] = 'FlowHooks::initFlowExtension';
 
diff --git a/Hooks.php b/Hooks.php
index a42167d..4aa7289 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -11,7 +11,6 @@
 use Flow\OccupationController;
 use Flow\SpamFilter\AbuseFilter;
 use Flow\TalkpageManager;
-use Flow\WorkflowLoader;
 use Flow\WorkflowLoaderFactory;
 use Flow\Data\Listener\RecentChangesListener;
 
@@ -1825,170 +1824,5 @@
                }
 
                return true;
-       }
-
-       public static function onNukeGetNewPages( $username, $pattern, 
$namespace, $limit, &$pages ) {
-               if ( $namespace && $namespace !== NS_TOPIC ) {
-                       // not interested in any Topics
-                       return true;
-               }
-
-               // Remove any pre-existing Topic pages.
-               // They are coming from the recentchanges table.
-               // Most likely the filters were not applied correctly.
-               $pages = array_filter( $pages, function( $entry ) {
-                       /** @var Title $title */
-                       $title = $entry[0];
-                       return $title->getNamespace() !== NS_TOPIC;
-               } );
-
-               if ( $pattern ) {
-                       // pattern is not supported
-                       return true;
-               }
-
-               if ( !RequestContext::getMain()->getUser()->isAllowed( 
'flow-delete' ) ) {
-                       // there's no point adding topics since the current 
user won't be allowed to delete them
-                       return true;
-               }
-
-               // how many are we allowed to retrieve now
-               $newLimit = $limit - count( $pages );
-               if ( $newLimit > 0 ) {
-
-                       $dbr = wfGetDB( DB_SLAVE );
-
-                       $userSelect = array( 'username' => 
"IFNULL(tree_orig_user_ip, user_name)" );
-                       $userWhere = array();
-                       if ( $username ) {
-                               $userSelect = array();
-                               $user = User::newFromName( $username );
-                               if ( $user ) {
-                                       $userWhere = array( 'tree_orig_user_id' 
=> $user->getId() );
-                               } else {
-                                       $userWhere = array( 'tree_orig_user_ip' 
=> $username );
-                               }
-                       }
-
-                       // limit results to the range of RC
-                       global $wgRCMaxAge;
-                       $rcTimeLimit = UUID::getComparisonUUID( 
strtotime("-$wgRCMaxAge seconds") );
-
-                       // get latest revision id for each topic
-                       // by the specified user (optional)
-                       $result = $dbr->select(
-                               array(
-                                       'r' => 'flow_revision',
-                                       'flow_tree_revision',
-                                       'flow_workflow',
-                                       'user'
-                               ),
-                               array_merge( array(
-                                       'revId' => 'MAX(r.rev_id)'
-                               ), $userSelect ),
-                               array_merge( array(
-                                       'tree_parent_id' => null,
-                                       'r.rev_type' => 'post',
-                                       'workflow_wiki' => wfWikiId(),
-                                       'workflow_id > ' . $dbr->addQuotes( 
$rcTimeLimit->getBinary() )
-                               ), $userWhere ),
-                               __METHOD__,
-                               array(
-                                       'GROUP BY' => 'r.rev_type_id'
-                               ),
-                               array(
-                                       'flow_tree_revision' => array( 'INNER 
JOIN', 'r.rev_type_id=tree_rev_descendant_id' ),
-                                       'flow_workflow' => array( 'INNER JOIN', 
'r.rev_type_id=workflow_id' ),
-                                       'user' => array( 'LEFT JOIN', 
'user_id=tree_orig_user_id' )
-                               )
-                       );
-
-                       $revIds = array();
-                       foreach( $result as $r ) {
-                               $revIds[$r->revId] = $username === '' ? 
$r->username : false;
-                       }
-
-                       // get non-moderated revisions
-                       $result = $dbr->select(
-                               'flow_revision',
-                               array(
-                                       'topicId' => 'rev_type_id',
-                                       'revId' => 'rev_id'
-                               ),
-                               array(
-                                       'rev_mod_state' => '',
-                                       'rev_id' => array_keys( $revIds )
-                               ),
-                               __METHOD__,
-                               array(
-                                       'LIMIT' => $newLimit,
-                                       'ORDER BY' => 'rev_type_id DESC'
-                               )
-                       );
-
-                       foreach( $result as $r ) {
-                               $topicTitle = Title::makeTitle( NS_TOPIC, 
UUID::create( $r->topicId )->getAlphadecimal() );
-                               $creatorUsername = $revIds[$r->revId];
-                               $pages[] = array( $topicTitle, $creatorUsername 
);
-                       }
-
-               }
-
-               return true;
-       }
-
-       public static function onNukeDeletePage( Title $title, $reason, 
&$deletionResult ) {
-               if ( $title->getNamespace() !== NS_TOPIC ) {
-                       // we don't handle it
-                       return true;
-               }
-
-               $action = 'moderate-topic';
-               $params = array(
-                       'topic' => array(
-                               'moderationState' => 'delete',
-                               'reason' => $reason,
-                               'page' => $title->getPrefixedText()
-                       ),
-               );
-
-               /** @var WorkflowLoaderFactory $factory */
-               $factory = Container::get( 'factory.loader.workflow' );
-
-               $workflowId = WorkflowLoaderFactory::uuidFromTitle( $title );
-               /** @var WorkflowLoader $loader */
-               $loader = $factory->createWorkflowLoader( $title, $workflowId );
-
-               $blocks = $loader->getBlocks();
-
-               $blocksToCommit = $loader->handleSubmit(
-                       RequestContext::getMain(),
-                       $action,
-                       $params
-               );
-
-               $result = true;
-               $errors = array();
-               foreach ( $blocks as $block ) {
-                       if ( $block->hasErrors() ) {
-                               $result = false;
-                               $errorKeys = $block->getErrors();
-                               foreach ( $errorKeys as $errorKey ) {
-                                       $errors[] = $block->getErrorMessage( 
$errorKey );
-                               }
-                       }
-               }
-
-               if ( $result ) {
-                       $loader->commit( $blocksToCommit );
-                       $deletionResult = true;
-               } else {
-                       $deletionResult = false;
-                       $msg = "Failed to delete {$title->getPrefixedText()}. 
Errors: " . implode( '. ', $errors );
-                       wfLogWarning( $msg );
-               }
-
-               // we've handled the deletion, abort the hook
-               return false;
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/259957
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I568c1a015de79f4d8b98805999f13d6053f82a5c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: wmf/1.27.0-wmf.9
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to