jenkins-bot has submitted this change and it was merged. Change subject: Move all Job classes into CirrusSearch\Job namespace ......................................................................
Move all Job classes into CirrusSearch\Job namespace Change-Id: Ib2e6ae0706cb39b75a53b108e3407773f53359cc --- M CirrusSearch.php M includes/Hooks.php R includes/Job/DeletePages.php R includes/Job/Job.php R includes/Job/LinksUpdate.php R includes/Job/LinksUpdateSecondary.php R includes/Job/MassIndex.php R includes/Job/OtherIndex.php M includes/Sanity/QueueingRemediator.php M includes/Updater.php M maintenance/forceSearchIndex.php 11 files changed, 47 insertions(+), 41 deletions(-) Approvals: Chad: Looks good to me, approved Manybubbles: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/CirrusSearch.php b/CirrusSearch.php index de2cacb..aa40500 100644 --- a/CirrusSearch.php +++ b/CirrusSearch.php @@ -397,6 +397,7 @@ $includes = __DIR__ . "/includes/"; $buildDocument = $includes . 'BuildDocument/'; +$jobsDir = $includes . 'Job/'; $maintenanceDir = $includes . 'Maintenance/'; $sanity = $includes . 'Sanity/'; $search = $includes . 'Search/'; @@ -412,24 +413,24 @@ $wgAutoloadClasses['CirrusSearch\BuildDocument\ParseBuilder'] = $buildDocument . 'Builder.php'; $wgAutoloadClasses['CirrusSearch\BuildDocument\RedirectsAndIncomingLinks'] = $buildDocument . 'RedirectsAndIncomingLinks.php'; $wgAutoloadClasses['CirrusSearch\Connection'] = $includes . 'Connection.php'; -$wgAutoloadClasses['CirrusSearch\DeletePagesJob'] = $includes . 'DeletePagesJob.php'; $wgAutoloadClasses['CirrusSearch\ElasticsearchIntermediary'] = $includes . 'ElasticsearchIntermediary.php'; $wgAutoloadClasses['CirrusSearch\ForceSearchIndex'] = __DIR__ . '/maintenance/forceSearchIndex.php'; $wgAutoloadClasses['CirrusSearch\Hooks'] = $includes . 'Hooks.php'; -$wgAutoloadClasses['CirrusSearch\LinksUpdateJob'] = $includes . 'LinksUpdateJob.php'; -$wgAutoloadClasses['CirrusSearch\LinksUpdateSecondaryJob'] = $includes . 'LinksUpdateSecondaryJob.php'; $wgAutoloadClasses['CirrusSearch\InterwikiSearcher'] = $includes . 'InterwikiSearcher.php'; -$wgAutoloadClasses['CirrusSearch\Job'] = $includes . 'Job.php'; +$wgAutoloadClasses['CirrusSearch\Job\Job'] = $jobsDir . 'Job.php'; +$wgAutoloadClasses['CirrusSearch\Job\DeletePages'] = $jobsDir . 'DeletePages.php'; +$wgAutoloadClasses['CirrusSearch\Job\LinksUpdate'] = $jobsDir . 'LinksUpdate.php'; +$wgAutoloadClasses['CirrusSearch\Job\LinksUpdateSecondary'] = $jobsDir . 'LinksUpdateSecondary.php'; +$wgAutoloadClasses['CirrusSearch\Job\MassIndex'] = $jobsDir . 'MassIndex.php'; +$wgAutoloadClasses['CirrusSearch\Job\OtherIndex'] = $jobsDir . 'OtherIndex.php'; $wgAutoloadClasses['CirrusSearch\Maintenance\AnalysisConfigBuilder'] = $maintenanceDir . 'AnalysisConfigBuilder.php'; $wgAutoloadClasses['CirrusSearch\Maintenance\CacheWarmers'] = $maintenanceDir . 'CacheWarmers.php'; $wgAutoloadClasses['CirrusSearch\Maintenance\ChunkBuilder'] = $maintenanceDir . 'ChunkBuilder.php'; $wgAutoloadClasses['CirrusSearch\Maintenance\ReindexForkController'] = $maintenanceDir . 'ReindexForkController.php'; $wgAutoloadClasses['CirrusSearch\Maintenance\MappingConfigBuilder'] = $maintenanceDir . 'MappingConfigBuilder.php'; $wgAutoloadClasses['CirrusSearch\Maintenance\ShardAllocation'] = $maintenanceDir . 'ShardAllocation.php'; -$wgAutoloadClasses['CirrusSearch\MassIndexJob'] = $includes . 'MassIndexJob.php'; $wgAutoloadClasses['CirrusSearch\NearMatchPicker'] = $includes . 'NearMatchPicker.php'; $wgAutoloadClasses['CirrusSearch\OtherIndexes'] = $includes . 'OtherIndexes.php'; -$wgAutoloadClasses['CirrusSearch\OtherIndexJob'] = $includes . 'OtherIndexJob.php'; $wgAutoloadClasses['CirrusSearch\Sanity\Checker'] = $sanity . 'Checker.php'; $wgAutoloadClasses['CirrusSearch\Sanity\NoopRemediator'] = $sanity . 'Remediator.php'; $wgAutoloadClasses['CirrusSearch\Sanity\PrintingRemediator'] = $sanity . 'Remediator.php'; @@ -480,12 +481,12 @@ /** * Jobs */ -$wgJobClasses[ 'cirrusSearchDeletePages' ] = 'CirrusSearch\DeletePagesJob'; -$wgJobClasses[ 'cirrusSearchLinksUpdate' ] = 'CirrusSearch\LinksUpdateJob'; -$wgJobClasses[ 'cirrusSearchLinksUpdatePrioritized' ] = 'CirrusSearch\LinksUpdateJob'; -$wgJobClasses[ 'cirrusSearchLinksUpdateSecondary' ] = 'CirrusSearch\LinksUpdateSecondaryJob'; -$wgJobClasses[ 'cirrusSearchMassIndex' ] = 'CirrusSearch\MassIndexJob'; -$wgJobClasses[ 'cirrusSearchOtherIndex' ] = 'CirrusSearch\OtherIndexJob'; +$wgJobClasses[ 'cirrusSearchDeletePages' ] = 'CirrusSearch\Job\DeletePages'; +$wgJobClasses[ 'cirrusSearchLinksUpdate' ] = 'CirrusSearch\Job\LinksUpdate'; +$wgJobClasses[ 'cirrusSearchLinksUpdatePrioritized' ] = 'CirrusSearch\Job\LinksUpdate'; +$wgJobClasses[ 'cirrusSearchLinksUpdateSecondary' ] = 'CirrusSearch\Job\LinksUpdateSecondary'; +$wgJobClasses[ 'cirrusSearchMassIndex' ] = 'CirrusSearch\Job\MassIndex'; +$wgJobClasses[ 'cirrusSearchOtherIndex' ] = 'CirrusSearch\Job\OtherIndex'; /** * Jenkins configuration required to get all the browser tests passing cleanly. diff --git a/includes/Hooks.php b/includes/Hooks.php index fadf8a4..18747d8 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -146,7 +146,7 @@ // DeferredUpdate so we don't end up racing our own page deletion DeferredUpdates::addCallableUpdate( function() use ( $target ) { JobQueueGroup::singleton()->push( - new LinksUpdateJob( $target, array( + new Job\LinksUpdate( $target, array( 'addedLinks' => array(), 'removedLinks' => array(), ) ) @@ -169,7 +169,7 @@ // Note that we must use the article id provided or it'll be lost in the ether. The job can't // load it from the title because the page row has already been deleted. JobQueueGroup::singleton()->push( - new DeletePagesJob( $page->getTitle(), array( 'id' => $pageId ) ) + new Job\DeletePages( $page->getTitle(), array( 'id' => $pageId ) ) ); return true; } @@ -184,7 +184,7 @@ */ public static function onAfterImportPage( $title ) { JobQueueGroup::singleton()->push( - MassIndexJob::build( + Job\MassIndex::build( array( WikiPage::factory( $title ) ), false, Updater::INDEX_EVERYTHING @@ -204,7 +204,7 @@ */ public static function onRevisionDelete( $title ) { JobQueueGroup::singleton()->push( - new LinksUpdateJob( $title, array( + new Job\LinksUpdate( $title, array( 'addedLinks' => array(), 'removedLinks' => array(), 'prioritize' => true @@ -300,7 +300,7 @@ if ( PHP_SAPI != 'cli' ) { $params[ 'prioritize' ] = true; } - $job = new LinksUpdateJob( $linksUpdate->getTitle(), $params ); + $job = new Job\LinksUpdate( $linksUpdate->getTitle(), $params ); JobQueueGroup::singleton()->push( $job ); return true; } @@ -397,7 +397,7 @@ // index to another. That only happens if it switches namespace. if ( $title->getNamespace() !== $newTitle->getNamespace() ) { $oldIndexType = Connection::getIndexSuffixForNamespace( $title->getNamespace() ); - JobQueueGroup::singleton()->push( new DeletePagesJob( $title, array( + JobQueueGroup::singleton()->push( new Job\DeletePages( $title, array( 'indexType' => $oldIndexType, 'id' => $oldId ) ) ); @@ -449,7 +449,7 @@ } /** - * Take a list of titles either linked or unlinked and prepare them for LinksUpdateJob. + * Take a list of titles either linked or unlinked and prepare them for Job\LinksUpdate. * This includes limiting them to $max titles. * @param array(Title) $titles titles to prepare * @param int $max maximum number of titles to return diff --git a/includes/DeletePagesJob.php b/includes/Job/DeletePages.php similarity index 94% rename from includes/DeletePagesJob.php rename to includes/Job/DeletePages.php index 8fe9e3a..40c9c64 100644 --- a/includes/DeletePagesJob.php +++ b/includes/Job/DeletePages.php @@ -1,6 +1,7 @@ <?php -namespace CirrusSearch; +namespace CirrusSearch\Job; +use \CirrusSearch\Updater; /** * Job wrapper around Updater::deletePages. If indexType parameter is @@ -21,7 +22,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html */ -class DeletePagesJob extends Job { +class DeletePages extends Job { public function __construct( $title, $params ) { parent::__construct( $title, $params ); diff --git a/includes/Job.php b/includes/Job/Job.php similarity index 92% rename from includes/Job.php rename to includes/Job/Job.php index 4663fb4..051075c 100644 --- a/includes/Job.php +++ b/includes/Job/Job.php @@ -1,6 +1,6 @@ <?php -namespace CirrusSearch; +namespace CirrusSearch\Job; use \Job as MWJob; /** @@ -23,8 +23,8 @@ */ abstract class Job extends MWJob { public function __construct( $title, $params ) { - // eg: DeletePagesJob -> cirrusSearchDeletePages - $jobName = 'cirrusSearch' . str_replace( 'CirrusSearch\\', '', str_replace( 'Job', '', get_class( $this ) ) ); + // eg: DeletePages -> cirrusSearchDeletePages + $jobName = 'cirrusSearch' . str_replace( 'CirrusSearch\\Job\\', '', get_class( $this ) ); parent::__construct( $jobName, $title, $params ); // All CirrusSearch jobs are reasonably expensive. Most involve parsing and it diff --git a/includes/LinksUpdateJob.php b/includes/Job/LinksUpdate.php similarity index 94% rename from includes/LinksUpdateJob.php rename to includes/Job/LinksUpdate.php index 6781888..0c3faad 100644 --- a/includes/LinksUpdateJob.php +++ b/includes/Job/LinksUpdate.php @@ -1,6 +1,7 @@ <?php -namespace CirrusSearch; +namespace CirrusSearch\Job; +use \CirrusSearch\Updater; use \JobQueueGroup; /** @@ -28,7 +29,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html */ -class LinksUpdateJob extends Job { +class LinksUpdate extends Job { public function __construct( $title, $params ) { parent::__construct( $title, $params ); @@ -69,7 +70,7 @@ $params[ 'jobReleaseTimestamp' ] = time() + 2 * $wgCirrusSearchRefreshInterval + 1; } $jobQueueGroup->push( - new LinksUpdateSecondaryJob( $this->title, $params ) ); + new LinksUpdateSecondary( $this->title, $params ) ); } // All done diff --git a/includes/LinksUpdateSecondaryJob.php b/includes/Job/LinksUpdateSecondary.php similarity index 94% rename from includes/LinksUpdateSecondaryJob.php rename to includes/Job/LinksUpdateSecondary.php index 1902d02..efeed92 100644 --- a/includes/LinksUpdateSecondaryJob.php +++ b/includes/Job/LinksUpdateSecondary.php @@ -1,6 +1,7 @@ <?php -namespace CirrusSearch; +namespace CirrusSearch\Job; +use \CirrusSearch\Updater; use \Title; /** @@ -28,7 +29,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html */ -class LinksUpdateSecondaryJob extends Job { +class LinksUpdateSecondary extends Job { public function __construct( $title, $params ) { parent::__construct( $title, $params ); } diff --git a/includes/MassIndexJob.php b/includes/Job/MassIndex.php similarity index 95% rename from includes/MassIndexJob.php rename to includes/Job/MassIndex.php index 40b5ee8..e7170ad 100644 --- a/includes/MassIndexJob.php +++ b/includes/Job/MassIndex.php @@ -1,6 +1,7 @@ <?php -namespace CirrusSearch; +namespace CirrusSearch\Job; +use \CirrusSearch\Updater; use \Title; use \WikiPage; @@ -23,7 +24,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html */ -class MassIndexJob extends Job { +class MassIndex extends Job { public static function build( $pages, $updateFlags ) { // Strip $pages down to PrefixedDBKeys so we don't put a ton of stuff in the job queue. $pageDBKeys = array(); diff --git a/includes/OtherIndexJob.php b/includes/Job/OtherIndex.php similarity index 95% rename from includes/OtherIndexJob.php rename to includes/Job/OtherIndex.php index 55247ee..7bb0263 100644 --- a/includes/OtherIndexJob.php +++ b/includes/Job/OtherIndex.php @@ -1,6 +1,7 @@ <?php -namespace CirrusSearch; +namespace CirrusSearch\Job; +use CirrusSearch\OtherIndexes; use \JobQueueGroup; use \Title; @@ -22,7 +23,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html */ -class OtherIndexJob extends Job { +class OtherIndex extends Job { /** * Check if we need to make a job and inject one if so. * @param $titles array(Title) The title we might update diff --git a/includes/Sanity/QueueingRemediator.php b/includes/Sanity/QueueingRemediator.php index 164a13b..52d6fb8 100644 --- a/includes/Sanity/QueueingRemediator.php +++ b/includes/Sanity/QueueingRemediator.php @@ -1,8 +1,8 @@ <?php namespace CirrusSearch\Sanity; -use \CirrusSearch\DeletePagesJob; -use \CirrusSearch\LinksUpdateJob; +use \CirrusSearch\Job\DeletePages; +use \CirrusSearch\Job\LinksUpdate; use \JobQueueGroup; use \WikiPage; @@ -34,11 +34,11 @@ } public function ghostPageInIndex( $pageId, $title ) { JobQueueGroup::singleton()->push( - new DeletePagesJob( $title, array( 'id' => $pageId ) ) + new DeletePages( $title, array( 'id' => $pageId ) ) ); } public function pageInWrongIndex( $page, $wrongIndex ) { - JobQueueGroup::singleton()->push( new DeletePagesJob( $page->getTitle(), array( + JobQueueGroup::singleton()->push( new DeletePages( $page->getTitle(), array( 'indexType' => $wrongIndex, 'id' => $page->getId() ) ) ); @@ -47,7 +47,7 @@ private function pushLinksUpdateJob( $page ) { JobQueueGroup::singleton()->push( - new LinksUpdateJob( $page->getTitle(), array( + new LinksUpdate( $page->getTitle(), array( 'addedLinks' => array(), 'removedLinks' => array(), ) ) diff --git a/includes/Updater.php b/includes/Updater.php index 4c50ce4..57fa89e 100644 --- a/includes/Updater.php +++ b/includes/Updater.php @@ -182,7 +182,7 @@ Connection::setTimeout( $clientSideTimeout ); } - OtherIndexJob::queueIfRequired( $this->pagesToTitles( $pages ), true ); + Job\OtherIndex::queueIfRequired( $this->pagesToTitles( $pages ), true ); $allData = array_fill_keys( Connection::getAllIndexTypes(), array() ); foreach ( $this->buildDocumentsForPages( $pages, $flags ) as $document ) { @@ -218,7 +218,7 @@ public function deletePages( $titles, $ids, $clientSideTimeout = null, $indexType = null ) { $profiler = new ProfileSection( __METHOD__ ); - OtherIndexJob::queueIfRequired( $titles, false ); + Job\OtherIndex::queueIfRequired( $titles, false ); if ( $clientSideTimeout !== null ) { Connection::setTimeout( $clientSideTimeout ); diff --git a/maintenance/forceSearchIndex.php b/maintenance/forceSearchIndex.php index de41f0f..b9e8832 100644 --- a/maintenance/forceSearchIndex.php +++ b/maintenance/forceSearchIndex.php @@ -200,7 +200,7 @@ } while ( $this->pauseForJobs < $queueSize ); } } - JobQueueGroup::singleton()->push( MassIndexJob::build( $pages, $updateFlags ) ); + JobQueueGroup::singleton()->push( Job\MassIndex::build( $pages, $updateFlags ) ); } else { // Update size with the actual number of updated documents. $updater = new Updater(); -- To view, visit https://gerrit.wikimedia.org/r/147274 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib2e6ae0706cb39b75a53b108e3407773f53359cc Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: Chad <ch...@wikimedia.org> Gerrit-Reviewer: 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