EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/284260
Change subject: Apply more annotations/type signature updates
......................................................................
Apply more annotations/type signature updates
Change-Id: Iab515047b1a76028f9169cbf776c20ddaed4f2f7
---
M includes/BuildDocument/RedirectsAndIncomingLinks.php
M includes/Hooks.php
M includes/Job/MassIndex.php
M includes/Sanity/Checker.php
M includes/Searcher.php
M profiles/CommonTermsQueryProfiles.php
M profiles/RescoreProfiles.php
7 files changed, 63 insertions(+), 21 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch
refs/changes/60/284260/1
diff --git a/includes/BuildDocument/RedirectsAndIncomingLinks.php
b/includes/BuildDocument/RedirectsAndIncomingLinks.php
index d8a8aaa..6cc453a 100644
--- a/includes/BuildDocument/RedirectsAndIncomingLinks.php
+++ b/includes/BuildDocument/RedirectsAndIncomingLinks.php
@@ -9,6 +9,10 @@
use Elastica\Query\MatchAll;
use MediaWiki\Logger\LoggerFactory;
use SplObjectStorage;
+<<<<<<< HEAD
+=======
+use WikiPage;
+>>>>>>> 19b8a4e... Apply more annotations/type signature updates
/**
* Adds redirects and incoming links to the documents. These are done together
@@ -76,7 +80,7 @@
private function realBuildDocument( $doc, $title ) {
global $wgCirrusSearchIndexedRedirects;
- $outgoingLinksToCount = array( $title->getPrefixedDBKey() );
+ $outgoingLinksToCount = array( $title->getPrefixedDBkey() );
// Gather redirects to this page
$redirectTitles = $title->getBacklinkCache()
@@ -111,7 +115,10 @@
};
}
- private function realFinishBatch( $pages ) {
+ /**
+ * @param WikiPage[]
+ */
+ private function realFinishBatch( array $pages ) {
$linkCountClosureCount = count( $this->linkCountClosures );
if ( $linkCountClosureCount ) {
try {
@@ -129,7 +136,7 @@
} catch ( \Elastica\Exception\ExceptionInterface $e ) {
// Note that we still return the pages and
execute the update here, we just complain
$this->failure( $e );
- $pageIds = array_map( function( $page ) {
+ $pageIds = array_map( function( WikiPage $page
) {
return $page->getId();
}, $pages );
LoggerFactory::getInstance(
'CirrusSearchChangeFailed' )->info(
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 71f8fbf..314cbca 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -72,7 +72,7 @@
*
* @param WebRequest $request
*/
- private static function initializeForRequest( $request ) {
+ private static function initializeForRequest( WebRequest $request ) {
global $wgSearchType, $wgHooks,
$wgCirrusSearchUseExperimentalHighlighter,
$wgCirrusSearchPhraseRescoreWindowSize,
@@ -124,14 +124,14 @@
* Set $dest to the numeric value from $request->getVal( $name ) if it
is <= $limit
* or => $limit if upperLimit is false.
*/
- private static function overrideNumeric( &$dest, $request, $name,
$limit = null, $upperLimit = true ) {
+ private static function overrideNumeric( &$dest, WebRequest $request,
$name, $limit = null, $upperLimit = true ) {
Util::overrideNumeric( $dest, $request, $name, $limit,
$upperLimit );
}
/**
* Set $dest to $value when $request->getVal( $name ) contains $secret
*/
- private static function overrideSecret( &$dest, $secret, $request,
$name, $value = true ) {
+ private static function overrideSecret( &$dest, $secret, WebRequest
$request, $name, $value = true ) {
if ( $secret && $secret === $request->getVal( $name ) ) {
$dest = $value;
}
@@ -140,11 +140,14 @@
/**
* Set $dest to the true/false from $request->getVal( $name ) if yes/no.
*/
- private static function overrideYesNo( &$dest, $request, $name ) {
+ private static function overrideYesNo( &$dest, WebRequest $request,
$name ) {
Util::overrideYesNo( $dest, $request, $name );
}
- private static function overrideUseExtraPluginForRegex( $request ) {
+ /**
+ * @param WebRequest $request
+ */
+ private static function overrideUseExtraPluginForRegex( WebRequest
$request ) {
global $wgCirrusSearchWikimediaExtraPlugin;
$val = $request->getVal( 'cirrusAccelerateRegex' );
@@ -232,7 +235,7 @@
/**
* Override more like this settings from request URI parameters
*/
- private static function overrideMoreLikeThisOptions( $request ) {
+ private static function overrideMoreLikeThisOptions( WebRequest
$request ) {
global $wgCirrusSearchMoreLikeThisConfig,
$wgCirrusSearchMoreLikeThisUseFields,
$wgCirrusSearchMoreLikeThisAllowedFields,
@@ -392,14 +395,19 @@
return true;
}
- private static function addSearchFeedbackLink( $link, $specialSearch,
$out ) {
+ /**
+ * @param string $link
+ * @param SpecialSearch $specialSearch
+ * @param OutputPage $out
+ */
+ private static function addSearchFeedbackLink( $link, SpecialSearch
$specialSearch, OutputPage $out ) {
$anchor = Xml::element(
'a',
array( 'href' => $link ),
$specialSearch->msg( 'cirrussearch-give-feedback'
)->text()
);
$block = Html::rawElement( 'div', array(), $anchor );
- $out->addHtml( $block );
+ $out->addHTML( $block );
}
/**
@@ -690,6 +698,11 @@
return true;
}
+ /**
+ * @param string $term
+ * @param SearchResultSet &$titleMatches
+ * @param SearchResultSet &$textMatches
+ */
public static function onSpecialSearchResults( $term, &$titleMatches,
&$textMatches ) {
global $wgOut;
diff --git a/includes/Job/MassIndex.php b/includes/Job/MassIndex.php
index 7f19e16..61412ec 100644
--- a/includes/Job/MassIndex.php
+++ b/includes/Job/MassIndex.php
@@ -26,6 +26,12 @@
* http://www.gnu.org/copyleft/gpl.html
*/
class MassIndex extends Job {
+ /**
+ * @param WikiPage[] $pages
+ * @param int $updateFlags
+ * @param string|null $cluster
+ * @return MassIndex
+ */
public static function build( $pages, $updateFlags, $cluster = null ) {
// Strip $pages down to PrefixedDBKeys so we don't put a ton of
stuff in the job queue.
$pageDBKeys = array();
@@ -41,6 +47,10 @@
) );
}
+ /**
+ * @return bool
+ * @throws \MWException
+ */
protected function doJob() {
// Reload pages from pageIds to throw into the updater
$pageData = array();
diff --git a/includes/Sanity/Checker.php b/includes/Sanity/Checker.php
index 44ff378..5e58517 100644
--- a/includes/Sanity/Checker.php
+++ b/includes/Sanity/Checker.php
@@ -70,12 +70,12 @@
* @return Status status of the operation
*/
public function check( $pageId ) {
- $fromIndex = $this->searcher->get( array( $pageId ), array(
'namespace', 'title' ) );
- if ( $fromIndex->isOK() ) {
- $fromIndex = $fromIndex->getValue();
- } else {
- return $fromIndex;
+ $status = $this->searcher->get( array( $pageId ), array(
'namespace', 'title' ) );
+ if ( !$status->isOK() ) {
+ return $status;
}
+ $fromIndex = $status->getValue();
+
$inIndex = count( $fromIndex ) > 0;
$page = WikiPage::newFromID( $pageId );
diff --git a/includes/Searcher.php b/includes/Searcher.php
index 74b1fc3..402a340 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -409,7 +409,7 @@
$this->extractSpecialSyntaxFromTerm(
'/^\s*local:/',
- function ( $matches ) {
+ function () {
$this->limitSearchToLocalWiki( true );
return '';
}
@@ -1622,12 +1622,12 @@
return;
}
$namespaceName = substr( $query, 0, $colon );
- $foundNamespace = $this->findNamespace( $namespaceName );
+ $status = $this->findNamespace( $namespaceName );
// Failure case is already logged so just handle success case
- if ( !$foundNamespace->isOK() ) {
+ if ( !$status->isOK() ) {
return;
}
- $foundNamespace = $foundNamespace->getValue();
+ $foundNamespace = $status->getValue();
if ( !$foundNamespace ) {
return;
}
diff --git a/profiles/CommonTermsQueryProfiles.php
b/profiles/CommonTermsQueryProfiles.php
index 3dca4e7..f3a848d 100644
--- a/profiles/CommonTermsQueryProfiles.php
+++ b/profiles/CommonTermsQueryProfiles.php
@@ -1,6 +1,9 @@
<?php
namespace CirrusSearch;
+
+use WebRequest;
+
/**
* CirrusSearch - List of profiles for CommonsTermQuery
* see
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html
@@ -81,6 +84,9 @@
);
class CommonTermsQueryProfiles {
+ /**
+ * @param WebRequest $request
+ */
public static function overrideOptions( $request ) {
global $wgCirrusSearchUseCommonTermsQuery,
$wgCirrusSearchCommonTermsQueryProfile,
diff --git a/profiles/RescoreProfiles.php b/profiles/RescoreProfiles.php
index d65922c..2c65034 100644
--- a/profiles/RescoreProfiles.php
+++ b/profiles/RescoreProfiles.php
@@ -1,6 +1,9 @@
<?php
namespace CirrusSearch;
+
+use WebRequest;
+
/**
* CirrusSearch - List of profiles for function score rescores.
*
@@ -243,7 +246,10 @@
* Used by includes/Hooks.php
*/
class RescoreProfiles {
- public static function overrideOptions( $request ) {
+ /**
+ * @param WebRequest $request
+ */
+ public static function overrideOptions( WebRequest $request ) {
global $wgCirrusSearchRescoreProfile,
$wgCirrusSearchPrefixSearchRescoreProfile,
$wgCirrusSearchMoreLikeRescoreProfile,
--
To view, visit https://gerrit.wikimedia.org/r/284260
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab515047b1a76028f9169cbf776c20ddaed4f2f7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits