EBernhardson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/223664

Change subject: Revert "Clean up empty result set scenario"
......................................................................

Revert "Clean up empty result set scenario"

I shouldn't have +2'd this one, it still isn't passing all the tests. This 
should be revived, the alternate approach
being deployed (Id46545dd77a) is a bandaid.
This reverts commit 2c7b406d9ddc719b9f1665e0797fc0ba3f56278f.

Change-Id: Ibc0759e4317285464becee2aa917fe367c614617
---
M autoload.php
M includes/CirrusSearch.php
D includes/Search/EmptyResultSet.php
M includes/Search/ResultSet.php
M includes/Searcher.php
5 files changed, 13 insertions(+), 59 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/64/223664/1

diff --git a/autoload.php b/autoload.php
index 956583c..0297c6b 100644
--- a/autoload.php
+++ b/autoload.php
@@ -63,7 +63,6 @@
        'CirrusSearch\\Sanity\\PrintingRemediator' => __DIR__ . 
'/includes/Sanity/Remediator.php',
        'CirrusSearch\\Sanity\\QueueingRemediator' => __DIR__ . 
'/includes/Sanity/QueueingRemediator.php',
        'CirrusSearch\\Sanity\\Remediator' => __DIR__ . 
'/includes/Sanity/Remediator.php',
-       'CirrusSearch\\Search\\EmptyResultSet' => __DIR__ . 
'/includes/Search/EmptyResultSet.php',
        'CirrusSearch\\Search\\Escaper' => __DIR__ . 
'/includes/Search/Escaper.php',
        'CirrusSearch\\Search\\EscaperTest' => __DIR__ . 
'/tests/unit/Search/EscaperTest.php',
        'CirrusSearch\\Search\\FancyTitleResultsType' => __DIR__ . 
'/includes/Search/ResultsType.php',
diff --git a/includes/CirrusSearch.php b/includes/CirrusSearch.php
index d3b977f..f16c47e 100644
--- a/includes/CirrusSearch.php
+++ b/includes/CirrusSearch.php
@@ -1,7 +1,6 @@
 <?php
 
 use CirrusSearch\InterwikiSearcher;
-use CirrusSearch\Search\EmptyResultSet;
 use CirrusSearch\Search\FullTextResultsType;
 use CirrusSearch\Searcher;
 
@@ -201,7 +200,7 @@
                if ( count( $titles ) ) {
                        return $searcher->moreLikeTheseArticles( $titles, 
$options );
                }
-               return Status::newGood( new EmptyResultSet( true ) );
+               return Status::newGood( new SearchResultSet() /* empty */ );
        }
        /**
         * Merge the prefix into the query (if any).
diff --git a/includes/Search/EmptyResultSet.php 
b/includes/Search/EmptyResultSet.php
deleted file mode 100644
index c7c7f48..0000000
--- a/includes/Search/EmptyResultSet.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-namespace CirrusSearch\Search;
-
-/**
- * An empty set of results from Elasticsearch
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- */
-class EmptyResultSet extends ResultSet {
-       /**
-        * Constructor.
-        * @param bool $containedSyntax Did the search query contain advanced 
syntax
-        */
-       public function __construct( $containedSyntax = false ) {
-               $this->containedSyntax = $containedSyntax;
-       }
-}
diff --git a/includes/Search/ResultSet.php b/includes/Search/ResultSet.php
index 8285bcd..40dcef2 100644
--- a/includes/Search/ResultSet.php
+++ b/includes/Search/ResultSet.php
@@ -24,32 +24,13 @@
  * http://www.gnu.org/copyleft/gpl.html
  */
 class ResultSet extends SearchResultSet {
-       /**
-        * Number of hits in this result set, and number of total hits found by
-        * the query
-        * @var int
-        */
-       private $hits, $totalHits = 0;
-
-       /**
-        * @var string
-        */
-       private $suggestionQuery, $suggestionSnippet = '';
-
-       /**
-        * Result wrapper
-        */
-       private $result;
-
-       /**
-        * An array of ResultSets for various interwiki searches
-        * @var array
-        */
-       private $interwikiResults = array();
+       private $result, $hits, $totalHits, $suggestionQuery, 
$suggestionSnippet;
+       private $searchContainedSyntax;
+       private $interwikiPrefix, $interwikiResults;
 
        public function __construct( $suggestPrefixes, $suggestSuffixes, $res, 
$searchContainedSyntax, $interwiki = '' ) {
                $this->result = $res;
-               $this->containedSyntax = $searchContainedSyntax;
+               $this->searchContainedSyntax = $searchContainedSyntax;
                $this->hits = $res->count();
                $this->totalHits = $res->getTotalHits();
                $this->interwikiPrefix = $interwiki;
@@ -179,4 +160,8 @@
        public function getInterwikiResults() {
                return $this->interwikiResults;
        }
+
+       public function searchContainedSyntax() {
+               return $this->searchContainedSyntax;
+       }
 }
diff --git a/includes/Searcher.php b/includes/Searcher.php
index 3ec2749..5586ebf 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -12,6 +12,7 @@
 use \Language;
 use \MWNamespace;
 use \RequestContext;
+use \SearchResultSet;
 use \Status;
 use \Title;
 use \UsageException;
@@ -568,7 +569,7 @@
                        }
                );
                if ( $isEmptyQuery ) {
-                       return Status::newGood( new EmptyResultSet( true ) );
+                       return Status::newGood( new SearchResultSet( true ) );
                }
                $this->filters = $filters;
                $this->notFilters = $notFilters;
@@ -819,7 +820,7 @@
                // This can happen if the user override this setting with field 
names that
                // are not allowed in $wgCirrusSearchMoreLikeThisAllowedFields 
(see Hooks.php)
                if( !$wgCirrusSearchMoreLikeThisFields ) {
-                       return Status::newGood( new EmptyResultSet() );
+                       return Status::newGood( new SearchResultSet() /* empty 
*/ );
                }
 
                $this->query = new \Elastica\Query\MoreLikeThis();
@@ -843,7 +844,7 @@
                        $found = $found->getValue();
                        if ( count( $found ) === 0 ) {
                                // If none of the pages are in the index we 
can't find articles like them
-                               return Status::newGood( new EmptyResultSet() );
+                               return Status::newGood( new SearchResultSet() 
/* empty */ );
                        }
                        foreach ( $found as $foundArticle ) {
                                $text[] = $foundArticle->text;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc0759e4317285464becee2aa917fe367c614617
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

Reply via email to