Aude has uploaded a new change for review. https://gerrit.wikimedia.org/r/256427
Change subject: Don't load WikiPage (w/ READ_LATEST) if search-update is not supported ...................................................................... Don't load WikiPage (w/ READ_LATEST) if search-update is not supported instead lazy load WikiPage, when needed. Change-Id: If67057b0b76f0f889ed498d8bbedaaeae3b2785d --- M includes/deferred/SearchUpdate.php 1 file changed, 21 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/27/256427/1 diff --git a/includes/deferred/SearchUpdate.php b/includes/deferred/SearchUpdate.php index f6c80f4..2abf028 100644 --- a/includes/deferred/SearchUpdate.php +++ b/includes/deferred/SearchUpdate.php @@ -38,6 +38,9 @@ /** @var Content|bool Content of the page (not text) */ private $content; + /** @var WikiPage **/ + private $page; + /** * Constructor * @@ -78,8 +81,6 @@ return; } - $page = WikiPage::newFromID( $this->id, WikiPage::READ_LATEST ); - foreach ( SearchEngine::getSearchTypes() as $type ) { $search = SearchEngine::create( $type ); if ( !$search->supports( 'search-update' ) ) { @@ -88,7 +89,7 @@ $normalTitle = $this->getNormalizedTitle( $search ); - if ( $page === null ) { + if ( $this->getLatestPage() === null ) { $search->delete( $this->id, $normalTitle ); continue; } elseif ( $this->content === false ) { @@ -173,6 +174,23 @@ } /** + * Get WikiPage for the SearchUpdate $id using WikiPage::READ_LATEST + * and ensure using the same WikiPage object if there are multiple + * SearchEngine types. + * + * Returns null if a page has been deleted or is not found. + * + * @return WikiPage|null + */ + private function getLatestPage() { + if ( !isset( $this->page ) ) { + $this->page = WikiPage::newFromID( $this->id, WikiPage::READ_LATEST ); + } + + return $this->page; + } + + /** * Get a normalized string representation of a title suitable for * including in a search index * -- To view, visit https://gerrit.wikimedia.org/r/256427 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If67057b0b76f0f889ed498d8bbedaaeae3b2785d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aude <aude.w...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits