jenkins-bot has submitted this change and it was merged.

Change subject: Clean up RevisionDelete hook to use LinksUpdate code
......................................................................


Clean up RevisionDelete hook to use LinksUpdate code

The UpdatePagesJob code is for bulk indexing, not this

Change-Id: Iddb783881e2a5e92f6f53fb913f76e97e996e451
---
M includes/Hooks.php
M includes/LinksUpdateJob.php
M includes/UpdatePagesJob.php
M includes/Updater.php
4 files changed, 16 insertions(+), 11 deletions(-)

Approvals:
  Manybubbles: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Hooks.php b/includes/Hooks.php
index 58c15b1..44695ba 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -96,9 +96,12 @@
         * @return bool
         */
        public static function onRevisionDelete( $title ) {
-               $page = WikiPage::factory( $title );
                JobQueueGroup::singleton()->push(
-                       UpdatePagesJob::build( array( $page ), true, 
Updater::INDEX_EVERYTHING )
+                       new LinksUpdateJob( $title, array(
+                               'checkFreshness' => true,
+                               'addedLinks' => array(),
+                               'removedLinks' => array()
+                       ) )
                );
        }
 
diff --git a/includes/LinksUpdateJob.php b/includes/LinksUpdateJob.php
index 456cb6d..60a70b2 100644
--- a/includes/LinksUpdateJob.php
+++ b/includes/LinksUpdateJob.php
@@ -42,15 +42,16 @@
 
        protected function doJob() {
                $updater = new Updater();
-               $updater->updateFromTitle( $this->title );
+               $check = isset( $this->params['checkFreshness'] ) && 
$this->params['checkFreshness'];
+               $updater->updateFromTitle( $this->title, $check );
                if ( count( $this->params[ 'addedLinks' ] ) > 0 ||
                                count( $this->params[ 'removedLinks' ] ) > 0 ) {
-                       $params = array(
-                               'addedLinks' => $this->params[ 'addedLinks' ],
-                               'removedLinks' => $this->params[ 'removedLinks' 
],
+                       JobQueueGroup::singleton()->push(
+                               new LinksUpdateSecondaryJob( $this->title, 
array(
+                                       'addedLinks' => $this->params[ 
'addedLinks' ],
+                                       'removedLinks' => $this->params[ 
'removedLinks' ],
+                               ) )
                        );
-                       $next = new LinksUpdateSecondaryJob( $this->title, 
$params );
-                       JobQueueGroup::singleton()->push( $next );
                }
        }
 
diff --git a/includes/UpdatePagesJob.php b/includes/UpdatePagesJob.php
index da7711e..46dd144 100644
--- a/includes/UpdatePagesJob.php
+++ b/includes/UpdatePagesJob.php
@@ -6,7 +6,7 @@
 
 /**
  * Job wrapper around Updater::updatePages.  Used by forceSearchIndex.php
- * when in job queueing mode and by Cirrus's revision delete hook.
+ * when in job queueing mode.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
diff --git a/includes/Updater.php b/includes/Updater.php
index 7a7bf02..6c9c027 100644
--- a/includes/Updater.php
+++ b/includes/Updater.php
@@ -50,13 +50,14 @@
        /**
         * Update a single page.
         * @param Title $title
+        * @param bool $checkFreshness Whether to check page freshness when 
updating
         */
-       public function updateFromTitle( $title ) {
+       public function updateFromTitle( $title, $checkFreshness = false ) {
                global $wgCirrusSearchShardTimeout, 
$wgCirrusSearchClientSideUpdateTimeout;
 
                $page = $this->traceRedirects( $title );
                if ( $page ) {
-                       $this->updatePages( array( $page ), false, 
$wgCirrusSearchShardTimeout,
+                       $this->updatePages( array( $page ), $checkFreshness, 
$wgCirrusSearchShardTimeout,
                                $wgCirrusSearchClientSideUpdateTimeout, 
self::INDEX_EVERYTHING );
                }
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iddb783881e2a5e92f6f53fb913f76e97e996e451
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Chad <ch...@wikimedia.org>
Gerrit-Reviewer: Manybubbles <never...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to