jenkins-bot has submitted this change and it was merged.

Change subject: Add missing properties and methods to maint classes
......................................................................


Add missing properties and methods to maint classes

There were a few undefined properties we just magic into place, and
one method that somehow doesn't exist. Not sure how we havn't hit
an undefined method warning there yet...

It also turns out runSearch only worked with full text search, light
refactoring has fixed that and made prefix and completion search work
again.

Bug: T132625
Change-Id: If24f72e514535190369958dde6323d340ad88ea6
---
M includes/Sanity/Checker.php
M maintenance/forceSearchIndex.php
M maintenance/runSearch.php
M maintenance/saneitize.php
M maintenance/updateSuggesterIndex.php
5 files changed, 84 insertions(+), 21 deletions(-)

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



diff --git a/includes/Sanity/Checker.php b/includes/Sanity/Checker.php
index eec49f0..f8b3718 100644
--- a/includes/Sanity/Checker.php
+++ b/includes/Sanity/Checker.php
@@ -28,9 +28,24 @@
  */
 
 class Checker {
+       /**
+        * @var Connection
+        */
        private $connection;
+
+       /**
+        * @var Searcher Used for fetching data, so we can check the content.
+        */
        private $searcher;
+
+       /**
+        * @var Remediator Do something with the problems we found
+        */
        private $remediator;
+
+       /**
+        * @var bool Should we log id's that are found to have no problems
+        */
        private $logSane;
 
        /**
@@ -39,9 +54,9 @@
         * @param Remediator $remediator the remediator to which to send titles
         *   that are insane
         * @param Searcher $searcher searcher to use for fetches
-        * @param boolean $logSane should we log sane ids
+        * @param bool $logSane should we log sane ids
         */
-       public function __construct( Connection $connection, $remediator, 
$searcher, $logSane ) {
+       public function __construct( Connection $connection, Remediator 
$remediator, Searcher $searcher, $logSane ) {
                $this->connection = $connection;
                $this->remediator = $remediator;
                $this->searcher = $searcher;
@@ -50,6 +65,7 @@
 
        /**
         * Check if a title is insane.
+        *
         * @param int $pageId page to check
         * @return Status status of the operation
         */
diff --git a/maintenance/forceSearchIndex.php b/maintenance/forceSearchIndex.php
index ac6af80..d7914ee 100644
--- a/maintenance/forceSearchIndex.php
+++ b/maintenance/forceSearchIndex.php
@@ -460,7 +460,7 @@
        private function findDeletes( $minUpdate, $minNamespace, $minTitle, 
$maxUpdate ) {
                $dbr = $this->getDB( DB_SLAVE );
                $minUpdate = $dbr->addQuotes( $dbr->timestamp( $minUpdate ) );
-               $minNamespace = $dbr->addQuotes( $minNamespace );
+               $minNamespace = $dbr->addQuotes( (string) $minNamespace );
                $minTitle = $dbr->addQuotes( $minTitle );
                $maxUpdate = $dbr->addQuotes( $dbr->timestamp( $maxUpdate ) );
                $where = array(
diff --git a/maintenance/runSearch.php b/maintenance/runSearch.php
index a008b03..17aa313 100644
--- a/maintenance/runSearch.php
+++ b/maintenance/runSearch.php
@@ -6,6 +6,7 @@
 use CirrusSearch\Searcher;
 use CirrusSearch\Search\ResultSet;
 use RequestContext;
+use SearchSuggestionSet;
 use Status;
 
 /**
@@ -135,16 +136,21 @@
                                        );
                                        $result = $value->next();
                                }
-                       } elseif ( is_array ($value ) ) {
+                       } elseif ( $value instanceof SearchSuggestionSet ) {
                                // these are suggestion results
-                               $data['totalHits'] = count( $value );
-                               foreach ( $value as $row ) {
+                               $data['totalHits'] = $value->getSize();
+                               foreach ( $value->getSuggestions() as 
$suggestion ) {
                                        $data['rows'][] = array(
-                                               'pageId' => $row['pageId'],
-                                               'title' => 
$row['title']->getPrefixedText(),
+                                               'pageId' => 
$suggestion->getSuggestedTitleID(),
+                                               'title' => 
$suggestion->getSuggestedTitle()->getPrefixedText(),
                                                'snippets' => array(),
                                        );
                                }
+                       } else {
+                               throw new \RuntimeException(
+                                       "Unknown result type: "
+                                       . is_object( $value ) ? get_class( 
$value ) : gettype( $value )
+                               );
                        }
                } else {
                        $data['error'] = $status->getMessage()->text();
@@ -165,12 +171,14 @@
                if ( $this->getOption( 'explain' ) ) {
                        RequestContext::getMain()->getRequest()->setVal( 
'cirrusExplain', true );
                }
+
+               $engine = new CirrusSearch( $this->indexBaseName );
+               $engine->setConnection( $this->getConnection() );
+               $engine->setLimitOffset( $limit );
+
                switch ( $searchType ) {
                case 'full_text':
                        // @todo pass through $this->getConnection() ?
-                       $engine = new CirrusSearch( $this->indexBaseName );
-                       $engine->setConnection( $this->getConnection() );
-                       $engine->setLimitOffset( $limit );
                        $result = $engine->searchText( $query );
                        if ( $result instanceof Status ) {
                                return $result;
@@ -179,12 +187,13 @@
                        }
 
                case 'prefix':
-                       $searcher = new Searcher( $this->getConnection(), 0, 
$limit, null, null, null, $this->indexBaseName );
-                       return $searcher->prefixSearch( $query );
+                       $titles = $engine->defaultPrefixSearch( $query );
+                       $resultSet = SearchSuggestionSet::fromTitles( $titles );
+                       return Status::newGood( $resultSet );
 
                case 'suggest':
-                       $searcher = new Searcher( $this->getConnection(), 0, 
$limit, null, null, null, $this->indexBaseName );
-                       $result = $searcher->suggest( $query );
+                       $engine->setFeatureData( 
CirrusSearch::COMPLETION_SUGGESTER_FEATURE, true );
+                       $result = $engine->completionSearch( $query );
                        if ( $result instanceof Status ) {
                                return $result;
                        } else {
diff --git a/maintenance/saneitize.php b/maintenance/saneitize.php
index 6576720..014709d 100644
--- a/maintenance/saneitize.php
+++ b/maintenance/saneitize.php
@@ -45,6 +45,13 @@
         */
        private $toId;
 
+       /**
+        * @var Checker Checks is the index is insane, and calls on a Remediator
+        *  instance to do something about it. The remediator may fix the issue,
+        *  log about it, or do a combination.
+        */
+       private $checker;
+
        public function __construct() {
                parent::__construct();
                $this->mDescription = "Make the index sane. Always operates on 
a single cluster.";
@@ -117,16 +124,21 @@
 
        private function buildChecker() {
                if ( $this->getOption( 'noop' ) ) {
-                       $this->remediator = new NoopRemediator();
+                       $remediator = new NoopRemediator();
                } else {
-                       $this->remediator = new QueueingRemediator( 
$this->getOption( 'cluster' ) );
+                       $remediator = new QueueingRemediator( $getOption( 
'cluster' ) );
                }
                if ( !$this->isQuiet() ) {
-                       $this->remediator = new PrintingRemediator( 
$this->remediator );
+                       $remediator = new PrintingRemediator( $remediator );
                }
                // This searcher searches all indexes for the current wiki.
                $searcher = new Searcher( $this->getConnection(), 0, 0, null, 
array(), null );
-               $this->checker = new Checker( $this->getConnection(), 
$this->remediator, $searcher, $this->getOption( 'logSane' ) );
+               $this->checker = new Checker(
+                       $this->getConnection(),
+                       $remediator,
+                       $searcher,
+                       $this->getOption( 'logSane' )
+               );
        }
 }
 
diff --git a/maintenance/updateSuggesterIndex.php 
b/maintenance/updateSuggesterIndex.php
index 4a27003..3f83ab5 100644
--- a/maintenance/updateSuggesterIndex.php
+++ b/maintenance/updateSuggesterIndex.php
@@ -8,8 +8,10 @@
 use CirrusSearch\Util;
 use CirrusSearch\BuildDocument\SuggestBuilder;
 use CirrusSearch\BuildDocument\SuggestScoringMethodFactory;
+use CirrusSearch\BuildDocument\SuggestScoringMethod;
 use CirrusSearch\Maintenance\Validators\AnalyzersValidator;
 use Elastica;
+use Elastica\Index;
 use Elastica\Query;
 use Elastica\Request;
 use Elastica\Status;
@@ -78,7 +80,7 @@
        private $scoreMethod;
 
        /**
-        * @var old suggester index that will be deleted at the end of the 
process
+        * @var Index old suggester index that will be deleted at the end of 
the process
         */
        private $oldIndex;
 
@@ -124,6 +126,21 @@
         */
        public $builder;
 
+       /**
+        * @var AnalysisConfigBuilder
+        */
+       private $analysisConfigBuilder;
+
+       /**
+        * @var bool
+        */
+       private $recycle = false;
+
+       /**
+        * @var string[]
+        */
+       private $bannedPlugins;
+
        public function __construct() {
                parent::__construct();
                $this->addDescription( "Create a new suggester index. Always 
operates on a single cluster." );
@@ -157,7 +174,8 @@
                global $wgLanguageCode,
                        $wgCirrusSearchBannedPlugins,
                        $wgPoolCounterConf,
-                       $wgCirrusSearchMasterTimeout;
+                       $wgCirrusSearchMasterTimeout,
+                       $wgCirrusSearchMaxShardsPerNode;
 
                $this->masterTimeout = $this->getOption( 'masterTimeout', 
$wgCirrusSearchMasterTimeout );
                $this->indexTypeName = Connection::TITLE_SUGGEST_TYPE;
@@ -772,6 +790,14 @@
        }
 
        /**
+        * @return \CirrusSearch\Maintenance\Validators\ShardAllocationValidator
+        */
+       private function getShardAllocationValidator() {
+               global $wgCirrusSearchIndexAllocation;
+               return new 
\CirrusSearch\Maintenance\Validators\ShardAllocationValidator( 
$this->getIndex(), $wgCirrusSearchIndexAllocation, $this );
+       }
+
+       /**
         * @return \Elastica\Index being updated
         */
        public function getIndex() {

-- 
To view, visit https://gerrit.wikimedia.org/r/283358
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If24f72e514535190369958dde6323d340ad88ea6
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <ebernhard...@wikimedia.org>
Gerrit-Reviewer: Cindy-the-browser-test-bot <bernhardsone...@gmail.com>
Gerrit-Reviewer: DCausse <dcau...@wikimedia.org>
Gerrit-Reviewer: EBernhardson <ebernhard...@wikimedia.org>
Gerrit-Reviewer: Gehel <gleder...@wikimedia.org>
Gerrit-Reviewer: Manybubbles <never...@wikimedia.org>
Gerrit-Reviewer: Smalyshev <smalys...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to