[MediaWiki-commits] [Gerrit] mediawiki...CirrusSearch[master]: Cleanup static analysis errors

2016-12-13 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/325835 )

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. A followup patch fixes scripts/run-phan.sh so cindy will
work properly again.

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(-)

Approvals:
  Cindy-the-browser-test-bot: Looks good to me, but someone else must approve
  jenkins-bot: Verified
  DCausse: Looks good to me, approved



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 

[MediaWiki-commits] [Gerrit] mediawiki...CirrusSearch[master]: Cleanup static analysis errors

2016-12-07 Thread EBernhardson (Code Review)
EBernhardson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/325835 )

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. A followup patch fixes scripts/run-phan.sh so cindy will
work properly again.

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/35/325835/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 >= 

[MediaWiki-commits] [Gerrit] mediawiki...CirrusSearch[master]: Cleanup static analysis errors

2016-12-07 Thread EBernhardson (Code Review)
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