EBernhardson has uploaded a new change for review. https://gerrit.wikimedia.org/r/291357
Change subject: Resolve deprecated method usage ...................................................................... Resolve deprecated method usage There were a number of deprecated methods being used, some because they were moved to MediaWikiServices in core, and others because we didn't want to make too many changes to master while he es2.x branch was alive. Now that es2.x is merged in it's safe to resolve all of these. Change-Id: Ia1e6abf168c2f41d54b29c8a19d7cd5710a05b71 --- M includes/Maintenance/Reindexer.php M includes/Util.php M maintenance/dumpIndex.php M maintenance/forceSearchIndex.php M maintenance/updateSuggesterIndex.php 5 files changed, 16 insertions(+), 35 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/57/291357/1 diff --git a/includes/Maintenance/Reindexer.php b/includes/Maintenance/Reindexer.php index 8b4021c..c22221c 100644 --- a/includes/Maintenance/Reindexer.php +++ b/includes/Maintenance/Reindexer.php @@ -13,6 +13,7 @@ use Elastica\Type; use ForkController; use MediaWiki\Logger\LoggerFactory; +use MWElasticUtils; /** * This program is free software; you can redistribute it and/or modify @@ -309,7 +310,7 @@ $this->outputIndented( $messagePrefix . "About to reindex $totalDocsToReindex documents\n" ); $operationStartTime = microtime( true ); $completed = 0; - Util::iterateOverScroll( $this->oldIndex, $result->getResponse()->getScrollId(), '1h', + MWElasticUtils::iterateOverScroll( $this->oldIndex, $result->getResponse()->getScrollId(), '1h', function( $results ) use ( $properties, $retryAttempts, $messagePrefix, $type, &$completed, $totalDocsToReindex, $operationStartTime ) { $documents = array(); @@ -411,7 +412,7 @@ * @return mixed */ private function withRetry( $attempts, $messagePrefix, $description, $func) { - return Util::withRetry ( $attempts, $func, + return MWElasticUtils::withRetry ( $attempts, $func, function( $e, $errors ) use ( $messagePrefix, $description ) { $this->sleepOnRetry( $e, $errors, $messagePrefix, $description ); } ); @@ -425,7 +426,7 @@ */ private function sleepOnRetry( ExceptionInterface $e, $errors, $messagePrefix, $description ) { $type = get_class( $e ); - $seconds = Util::backoffDelay( $errors ); + $seconds = MWElasticUtils::backoffDelay( $errors ); $message = ElasticsearchIntermediary::extractMessage( $e ); $this->outputIndented( $messagePrefix . "Caught an error $description. " . "Backing off for $seconds and retrying. Error type is '$type' and message is: $message\n" ); diff --git a/includes/Util.php b/includes/Util.php index 9672b0e..e53fd09 100644 --- a/includes/Util.php +++ b/includes/Util.php @@ -58,8 +58,9 @@ // then vary the namespace on gender like we should. $nsText = ''; if ( MWNamespace::hasGenderDistinction( $ns ) && $wgContLang->needsGenderDistinction() ) { - $nsText = $wgContLang->getGenderNsText( $ns, - GenderCache::singleton()->getGenderOf( + $nsText = $wgContLang->getGenderNsText( + $ns, + MediaWikiServices::getInstance()->getGenderCache()->getGenderOf( User::newFromName( $title->getText() ), __METHOD__ ) @@ -282,30 +283,6 @@ } return $data; - } - - /** - * @deprecated use MWElasticUtils::iterateOverScroll directly - */ - public static function iterateOverScroll( \Elastica\Index $index, - $scrollId, $scrollTime, $consumer, $limit = 0, $retryAttempts = 0, - $retryErrorCallback = null ) { - MWElasticUtils::iterateOverScroll( $index, $scrollId, $scrollTime, $consumer, - $limit, $retryAttempts, $retryErrorCallback ); - } - - /** - * @deprecated use MWElasticUtils::withRetry - */ - public static function withRetry( $attempts, $func, $beforeRetry = null ) { - MWElasticUtils::withRetry( $attempts, $func, $beforeRetry ); - } - - /** - * @deprecated use MWElasticUtils::backoffDelay - */ - public static function backoffDelay( $errorCount ) { - return MWElasticUtils::backoffDelay( $errorCount ); } /** diff --git a/maintenance/dumpIndex.php b/maintenance/dumpIndex.php index 804d64e..744965f 100644 --- a/maintenance/dumpIndex.php +++ b/maintenance/dumpIndex.php @@ -8,6 +8,7 @@ use Elastica\Index; use Elastica\JSON; use Elastica\Query; +use MWElasticUtils; /** * Dump an index to stdout @@ -155,7 +156,7 @@ $this->logToStderr = true; $this->output( "Dumping $totalDocsToDump documents ($totalDocsInIndex in the index)\n" ); - Util::iterateOverScroll( $index, $result->getResponse()->getScrollId(), '15m', + MWElasticUtils::iterateOverScroll( $index, $result->getResponse()->getScrollId(), '15m', function( $results ) use ( &$docsDumped, $totalDocsToDump ) { foreach ( $results as $result ) { $document = array( diff --git a/maintenance/forceSearchIndex.php b/maintenance/forceSearchIndex.php index eca4423..b4cd45b 100644 --- a/maintenance/forceSearchIndex.php +++ b/maintenance/forceSearchIndex.php @@ -7,6 +7,7 @@ use JobQueueGroup; use LinkCache; use MediaWiki\Logger\LoggerFactory; +use MediaWiki\MediaWikiServices; use MWException; use MWTimestamp; use Title; @@ -453,7 +454,7 @@ $result[] = $update; } // Clear the LinkCache to prevent its memory use from growing without bounds. - LinkCache::singleton()->clear(); + MediaWikiServices::getInstance()->getLinkCache()->clear(); return $result; } diff --git a/maintenance/updateSuggesterIndex.php b/maintenance/updateSuggesterIndex.php index 86140c0..949e8ab 100644 --- a/maintenance/updateSuggesterIndex.php +++ b/maintenance/updateSuggesterIndex.php @@ -15,6 +15,7 @@ use Elastica\Query; use Elastica\Request; use Elastica\Status; +use MWElasticUtils; /** * Update the search configuration on the search backend for the title @@ -427,7 +428,7 @@ $totalDocsToDump = $totalDocsInIndex; $this->log( "Deleting remaining docs from previous batch ($totalDocsInIndex).\n" ); - Util::iterateOverScroll( $this->getIndex(), $result->getResponse()->getScrollId(), '15m', + MWElasticUtils::iterateOverScroll( $this->getIndex(), $result->getResponse()->getScrollId(), '15m', function( $results ) use ( &$docsDumped, $totalDocsToDump ) { $ids = array(); foreach( $results as $result ) { @@ -435,7 +436,7 @@ $ids[] = $result->getId(); } $this->outputProgress( $docsDumped, $totalDocsToDump ); - Util::withRetry( $this->indexRetryAttempts, + MWElasticUtils::withRetry( $this->indexRetryAttempts, function() use ( $ids ) { $this->getType()->deleteIds( $ids ); } @@ -577,7 +578,7 @@ $destinationType = $this->getIndex()->getType( Connection::TITLE_SUGGEST_TYPE_NAME ); - Util::iterateOverScroll( $sourceIndex, $result->getResponse()->getScrollId(), '15m', + MWElasticUtils::iterateOverScroll( $sourceIndex, $result->getResponse()->getScrollId(), '15m', function( $results ) use ( &$docsDumped, $totalDocsToDump, $destinationType ) { $inputDocs = array(); @@ -591,7 +592,7 @@ $suggestDocs = $this->builder->build( $inputDocs ); $this->outputProgress( $docsDumped, $totalDocsToDump ); - Util::withRetry( $this->indexRetryAttempts, + MWElasticUtils::withRetry( $this->indexRetryAttempts, function() use ( $destinationType, $suggestDocs ) { $destinationType->addDocuments( $suggestDocs ); } -- To view, visit https://gerrit.wikimedia.org/r/291357 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia1e6abf168c2f41d54b29c8a19d7cd5710a05b71 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits