EBernhardson has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/325832 )
Change subject: Cleanup static analysis errors ...................................................................... Cleanup static analysis errors Phan has apparently been broken on cindy for a few weeks, so a few minor inconsistencies have snuck in. Nothing too major, just small cleanups. Change-Id: Ide9838ac77084253bf6cfd05e178062b39eac612 --- M includes/BaseInterwikiResolver.php M includes/CirrusSearch.php M includes/CompletionSuggester.php M includes/EmptyInterwikiResolver.php M includes/Maintenance/MetaStoreIndex.php M includes/Search/TitleHelper.php M includes/Searcher.php M includes/SiteMatrixInterwikiResolver.php 8 files changed, 15 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/32/325832/1 diff --git a/includes/BaseInterwikiResolver.php b/includes/BaseInterwikiResolver.php index d70ca91..0b13c83 100644 --- a/includes/BaseInterwikiResolver.php +++ b/includes/BaseInterwikiResolver.php @@ -9,7 +9,7 @@ * be stored by this base class. */ abstract class BaseInterwikiResolver implements InterwikiResolver { - /** @var array[]: full IW matrix (@see loadMatrix()) */ + /** @var array[]|null full IW matrix (@see loadMatrix()) */ private $matrix; /** diff --git a/includes/CirrusSearch.php b/includes/CirrusSearch.php index 2717105..a31e310 100644 --- a/includes/CirrusSearch.php +++ b/includes/CirrusSearch.php @@ -218,14 +218,14 @@ break; } } - if ( $detected === null ) { - Searcher::appendLastLogPayload( 'langdetect', 'failed' ); - return null; - } else { + if ( is_array( $detected ) ) { // Report language detection with search metrics // TODO: do we still need this metric? (see T151796) $this->extraSearchMetrics['wgCirrusSearchAltLanguage'] = $detected; return reset( $detected ); + } else { + Searcher::appendLastLogPayload( 'langdetect', 'failed' ); + return null; } } diff --git a/includes/CompletionSuggester.php b/includes/CompletionSuggester.php index 945c2df..3484a8b 100644 --- a/includes/CompletionSuggester.php +++ b/includes/CompletionSuggester.php @@ -186,6 +186,7 @@ 400 ); } else { + /** @suppress PhanDeprecatedClass */ throw new UsageException( 'Prefix search request was longer than the maximum allowed length.' . " ($requestLength > " . Searcher::MAX_TITLE_SEARCH . ')', 'request_too_long', 400 ); } @@ -227,10 +228,11 @@ 'CirrusSearch-Completion', $this->user, function() use( $index, $suggest, $queryOptions, $profiles, $text ) { - $log = $this->startNewLog( "{queryType} search for '{query}'", $this->queryType, [ + $log = $this->newLog( "{queryType} search for '{query}'", $this->queryType, [ 'query' => $text, 'offset' => $this->offset, ] ); + $this->start( $log ); try { $result = $index->request( "_suggest", Request::POST, $suggest, $queryOptions ); if( $result->isOk() ) { diff --git a/includes/EmptyInterwikiResolver.php b/includes/EmptyInterwikiResolver.php index a4da009..89d4623 100644 --- a/includes/EmptyInterwikiResolver.php +++ b/includes/EmptyInterwikiResolver.php @@ -11,6 +11,7 @@ } /** + * @param string $wikiId * @return string|null the interwiki identified for this $wikiId or null if none found */ public function getInterwikiPrefix( $wikiId ) { @@ -18,6 +19,7 @@ } /** + * @param string $lang * @return string[] a single elt array [ 'iw_prefix' => 'wikiId' ] or [] if none found */ public function getSameProjectWikiByLang( $lang ) { diff --git a/includes/Maintenance/MetaStoreIndex.php b/includes/Maintenance/MetaStoreIndex.php index 2b254b3..9d9f3a5 100644 --- a/includes/Maintenance/MetaStoreIndex.php +++ b/includes/Maintenance/MetaStoreIndex.php @@ -124,7 +124,7 @@ */ public function versionIsAtLeast( array $expected ) { // $expected >= $version - return version_compare( + return (bool)version_compare( implode( '.', $expected ), implode( '.', $this->metastoreVersion() ), '>=' diff --git a/includes/Search/TitleHelper.php b/includes/Search/TitleHelper.php index 16d50e2..304e7e0 100644 --- a/includes/Search/TitleHelper.php +++ b/includes/Search/TitleHelper.php @@ -75,6 +75,7 @@ return true; } // TODO: replace by return false when wiki is populated + /** @suppress PhanDeprecatedFunction */ return !empty( $this->getConfig()->getWikiCode() ); } @@ -89,6 +90,7 @@ ->getInterwikiPrefix( $r->wiki ); } // TODO: replace by return false when wiki is populated + /** @suppress PhanDeprecatedFunction */ return $this->getConfig()->getWikiCode(); } diff --git a/includes/Searcher.php b/includes/Searcher.php index ec9ebe6..957c563 100644 --- a/includes/Searcher.php +++ b/includes/Searcher.php @@ -842,6 +842,7 @@ 400 ); } else { + /** @suppress PhanDeprecatedClass */ throw new UsageException( 'Prefix search request was longer than the maximum allowed length.' . " ($requestLength > " . self::MAX_TITLE_SEARCH . ')', 'request_too_long', 400 ); } diff --git a/includes/SiteMatrixInterwikiResolver.php b/includes/SiteMatrixInterwikiResolver.php index 81a8cb1..34a7440 100644 --- a/includes/SiteMatrixInterwikiResolver.php +++ b/includes/SiteMatrixInterwikiResolver.php @@ -66,7 +66,7 @@ } /** - * @return array[] + * @return callable */ private function siteMatrixLoader() { return function() { -- To view, visit https://gerrit.wikimedia.org/r/325832 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ide9838ac77084253bf6cfd05e178062b39eac612 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