Split SearchResultSet.php classes
authorJustin Du <justin.d128@gmail.com>
Sun, 3 Jan 2016 23:10:32 +0000 (17:10 -0600)
committerJustin Du <justin.d128@gmail.com>
Sun, 3 Jan 2016 23:12:10 +0000 (17:12 -0600)
Change autoload.php file to accomodate the split

Bug: T122637
Change-Id: I3a326aa329c3be64662825ac06b169ae96b8f53c

autoload.php
includes/search/SearchNearMatchResultSet.php [new file with mode: 0644]
includes/search/SearchResultSet.php
includes/search/SqlSearchResultSet.php [new file with mode: 0644]

index 92c5436..46da116 100644 (file)
@@ -1101,7 +1101,7 @@ $wgAutoloadLocalClasses = array(
        'SearchHighlighter' => __DIR__ . '/includes/search/SearchHighlighter.php',
        'SearchMssql' => __DIR__ . '/includes/search/SearchMssql.php',
        'SearchMySQL' => __DIR__ . '/includes/search/SearchMySQL.php',
-       'SearchNearMatchResultSet' => __DIR__ . '/includes/search/SearchResultSet.php',
+       'SearchNearMatchResultSet' => __DIR__ . '/includes/search/SearchNearMatchResultSet.php',
        'SearchOracle' => __DIR__ . '/includes/search/SearchOracle.php',
        'SearchPostgres' => __DIR__ . '/includes/search/SearchPostgres.php',
        'SearchResult' => __DIR__ . '/includes/search/SearchResult.php',
@@ -1213,7 +1213,7 @@ $wgAutoloadLocalClasses = array(
        'SpecialWhatLinksHere' => __DIR__ . '/includes/specials/SpecialWhatlinkshere.php',
        'SqlBagOStuff' => __DIR__ . '/includes/objectcache/SqlBagOStuff.php',
        'SqlDataUpdate' => __DIR__ . '/includes/deferred/SqlDataUpdate.php',
-       'SqlSearchResultSet' => __DIR__ . '/includes/search/SearchResultSet.php',
+       'SqlSearchResultSet' => __DIR__ . '/includes/search/SqlSearchResultSet.php',
        'Sqlite' => __DIR__ . '/maintenance/sqlite.inc',
        'SqliteInstaller' => __DIR__ . '/includes/installer/SqliteInstaller.php',
        'SqliteMaintenance' => __DIR__ . '/maintenance/sqlite.php',
diff --git a/includes/search/SearchNearMatchResultSet.php b/includes/search/SearchNearMatchResultSet.php
new file mode 100644 (file)
index 0000000..cb4f81d
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+/**
+ * A SearchResultSet wrapper for SearchEngine::getNearMatch
+ */
+class SearchNearMatchResultSet extends SearchResultSet {
+       private $fetched = false;
+
+       /**
+        * @param Title|null $match Title if matched, else null
+        */
+       public function __construct( $match ) {
+               $this->result = $match;
+       }
+
+       public function numRows() {
+               return $this->result ? 1 : 0;
+       }
+
+       public function next() {
+               if ( $this->fetched || !$this->result ) {
+                       return false;
+               }
+               $this->fetched = true;
+               return SearchResult::newFromTitle( $this->result );
+       }
+}
index 8fb04e4..eccd36e 100644 (file)
@@ -171,89 +171,3 @@ class SearchResultSet {
                return $this->containedSyntax;
        }
 }
-
-/**
- * This class is used for different SQL-based search engines shipped with MediaWiki
- * @ingroup Search
- */
-class SqlSearchResultSet extends SearchResultSet {
-       protected $resultSet;
-       protected $terms;
-       protected $totalHits;
-
-       function __construct( $resultSet, $terms, $total = null ) {
-               $this->resultSet = $resultSet;
-               $this->terms = $terms;
-               $this->totalHits = $total;
-       }
-
-       function termMatches() {
-               return $this->terms;
-       }
-
-       function numRows() {
-               if ( $this->resultSet === false ) {
-                       return false;
-               }
-
-               return $this->resultSet->numRows();
-       }
-
-       function next() {
-               if ( $this->resultSet === false ) {
-                       return false;
-               }
-
-               $row = $this->resultSet->fetchObject();
-               if ( $row === false ) {
-                       return false;
-               }
-
-               return SearchResult::newFromTitle(
-                       Title::makeTitle( $row->page_namespace, $row->page_title )
-               );
-       }
-
-       function free() {
-               if ( $this->resultSet === false ) {
-                       return false;
-               }
-
-               $this->resultSet->free();
-       }
-
-       function getTotalHits() {
-               if ( !is_null( $this->totalHits ) ) {
-                       return $this->totalHits;
-               } else {
-                       // Special:Search expects a number here.
-                       return $this->numRows();
-               }
-       }
-}
-
-/**
- * A SearchResultSet wrapper for SearchEngine::getNearMatch
- */
-class SearchNearMatchResultSet extends SearchResultSet {
-       private $fetched = false;
-
-       /**
-        * @param Title|null $match Title if matched, else null
-        */
-       public function __construct( $match ) {
-               $this->result = $match;
-       }
-
-       public function numRows() {
-               return $this->result ? 1 : 0;
-       }
-
-       public function next() {
-               if ( $this->fetched || !$this->result ) {
-                       return false;
-               }
-               $this->fetched = true;
-               return SearchResult::newFromTitle( $this->result );
-       }
-}
diff --git a/includes/search/SqlSearchResultSet.php b/includes/search/SqlSearchResultSet.php
new file mode 100644 (file)
index 0000000..7a6aaf7
--- /dev/null
@@ -0,0 +1,60 @@
+<?php
+/**
+ * This class is used for different SQL-based search engines shipped with MediaWiki
+ * @ingroup Search
+ */
+class SqlSearchResultSet extends SearchResultSet {
+       protected $resultSet;
+       protected $terms;
+       protected $totalHits;
+
+       function __construct( $resultSet, $terms, $total = null ) {
+               $this->resultSet = $resultSet;
+               $this->terms = $terms;
+               $this->totalHits = $total;
+       }
+
+       function termMatches() {
+               return $this->terms;
+       }
+
+       function numRows() {
+               if ( $this->resultSet === false ) {
+                       return false;
+               }
+
+               return $this->resultSet->numRows();
+       }
+
+       function next() {
+               if ( $this->resultSet === false ) {
+                       return false;
+               }
+
+               $row = $this->resultSet->fetchObject();
+               if ( $row === false ) {
+                       return false;
+               }
+
+               return SearchResult::newFromTitle(
+                       Title::makeTitle( $row->page_namespace, $row->page_title )
+               );
+       }
+
+       function free() {
+               if ( $this->resultSet === false ) {
+                       return false;
+               }
+
+               $this->resultSet->free();
+       }
+
+       function getTotalHits() {
+               if ( !is_null( $this->totalHits ) ) {
+                       return $this->totalHits;
+               } else {
+                       // Special:Search expects a number here.
+                       return $this->numRows();
+               }
+       }
+}