Merge "Deprecate overriding SearchEngine::search*"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 16 May 2018 13:31:56 +0000 (13:31 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 16 May 2018 13:31:56 +0000 (13:31 +0000)
RELEASE-NOTES-1.32
includes/search/SearchEngine.php
includes/search/SearchMssql.php
includes/search/SearchMySQL.php
includes/search/SearchOracle.php
includes/search/SearchPostgres.php
includes/search/SearchResultSet.php
includes/search/SearchSqlite.php

index 8e44910..4c56eec 100644 (file)
@@ -96,6 +96,9 @@ because of Phabricator reports.
   of queueing style modules as well.
 * OutputPage::addModuleScripts() and ParserOutput::addModuleScripts are
   deprecated. Use addModules() instead.
+* Overriding SearchEngine::{searchText,searchTitle,searchArchiveTitle}
+  in extending classes is deprecated.  Extend related doSearch* methods
+  instead.
 
 === Other changes in 1.32 ===
 * …
index 0f65711..bd48e21 100644 (file)
@@ -69,12 +69,25 @@ abstract class SearchEngine {
        /**
         * Perform a full text search query and return a result set.
         * If full text searches are not supported or disabled, return null.
-        * STUB
+        *
+        * As of 1.32 overriding this function is deprecated. It will
+        * be converted to final in 1.34. Override self::doSearchText().
+        *
+        * @param string $term Raw search term
+        * @return SearchResultSet|Status|null
+        */
+       public function searchText( $term ) {
+               return $this->doSearchText( $term );
+       }
+
+       /**
+        * Perform a full text search query and return a result set.
         *
         * @param string $term Raw search term
         * @return SearchResultSet|Status|null
+        * @since 1.32
         */
-       function searchText( $term ) {
+       protected function doSearchText( $term ) {
                return null;
        }
 
@@ -85,11 +98,25 @@ abstract class SearchEngine {
         * The results returned by this methods are only sugegstions and
         * may not end up being shown to the user.
         *
+        * As of 1.32 overriding this function is deprecated. It will
+        * be converted to final in 1.34. Override self::doSearchArchiveTitle().
+        *
         * @param string $term Raw search term
         * @return Status<Title[]>
         * @since 1.29
         */
-       function searchArchiveTitle( $term ) {
+       public function searchArchiveTitle( $term ) {
+               return $this->doSearchArchiveTitle( $term );
+       }
+
+       /**
+        * Perform a title search in the article archive.
+        *
+        * @param string $term Raw search term
+        * @return Status<Title[]>
+        * @since 1.32
+        */
+       protected function doSearchArchiveTitle( $term ) {
                return Status::newGood( [] );
        }
 
@@ -98,10 +125,24 @@ abstract class SearchEngine {
         * If title searches are not supported or disabled, return null.
         * STUB
         *
+        * As of 1.32 overriding this function is deprecated. It will
+        * be converted to final in 1.34. Override self::doSearchTitle().
+        *
+        * @param string $term Raw search term
+        * @return SearchResultSet|null
+        */
+       public function searchTitle( $term ) {
+               return $this->doSearchTitle( $term );
+       }
+
+       /**
+        * Perform a title-only search query and return a result set.
+        *
         * @param string $term Raw search term
         * @return SearchResultSet|null
+        * @since 1.32
         */
-       function searchTitle( $term ) {
+       protected function doSearchTitle( $term ) {
                return null;
        }
 
index 3b55b89..43bd3be 100644 (file)
@@ -31,9 +31,8 @@ class SearchMssql extends SearchDatabase {
         *
         * @param string $term Raw search term
         * @return SqlSearchResultSet
-        * @access public
         */
-       function searchText( $term ) {
+       protected function doSearchText( $term ) {
                $resultSet = $this->db->query( $this->getQuery( $this->filter( $term ), true ) );
                return new SqlSearchResultSet( $resultSet, $this->searchTerms );
        }
@@ -43,9 +42,8 @@ class SearchMssql extends SearchDatabase {
         *
         * @param string $term Raw search term
         * @return SqlSearchResultSet
-        * @access public
         */
-       function searchTitle( $term ) {
+       protected function doSearchTitle( $term ) {
                $resultSet = $this->db->query( $this->getQuery( $this->filter( $term ), false ) );
                return new SqlSearchResultSet( $resultSet, $this->searchTerms );
        }
index 3ae8837..9a03ebe 100644 (file)
@@ -167,7 +167,7 @@ class SearchMySQL extends SearchDatabase {
         * @param string $term Raw search term
         * @return SqlSearchResultSet
         */
-       function searchText( $term ) {
+       protected function doSearchText( $term ) {
                return $this->searchInternal( $term, true );
        }
 
@@ -177,7 +177,7 @@ class SearchMySQL extends SearchDatabase {
         * @param string $term Raw search term
         * @return SqlSearchResultSet
         */
-       function searchTitle( $term ) {
+       protected function doSearchTitle( $term ) {
                return $this->searchInternal( $term, false );
        }
 
index f38d0db..7fe5b53 100644 (file)
@@ -64,7 +64,7 @@ class SearchOracle extends SearchDatabase {
         * @param string $term Raw search term
         * @return SqlSearchResultSet
         */
-       function searchText( $term ) {
+       protected function doSearchText( $term ) {
                if ( $term == '' ) {
                        return new SqlSearchResultSet( false, '' );
                }
@@ -79,7 +79,7 @@ class SearchOracle extends SearchDatabase {
         * @param string $term Raw search term
         * @return SqlSearchResultSet
         */
-       function searchTitle( $term ) {
+       protected function doSearchTitle( $term ) {
                if ( $term == '' ) {
                        return new SqlSearchResultSet( false, '' );
                }
index f660e7a..729e528 100644 (file)
@@ -37,7 +37,7 @@ class SearchPostgres extends SearchDatabase {
         * @param string $term Raw search term
         * @return SqlSearchResultSet
         */
-       function searchTitle( $term ) {
+       protected function doSearchTitle( $term ) {
                $q = $this->searchQuery( $term, 'titlevector', 'page_title' );
                $olderror = error_reporting( E_ERROR );
                $resultSet = $this->db->query( $q, 'SearchPostgres', true );
@@ -45,7 +45,7 @@ class SearchPostgres extends SearchDatabase {
                return new SqlSearchResultSet( $resultSet, $this->searchTerms );
        }
 
-       function searchText( $term ) {
+       protected function doSearchText( $term ) {
                $q = $this->searchQuery( $term, 'textvector', 'old_text' );
                $olderror = error_reporting( E_ERROR );
                $resultSet = $this->db->query( $q, 'SearchPostgres', true );
index f25c728..e3eb4c2 100644 (file)
@@ -173,6 +173,7 @@ class SearchResultSet {
         * Fetches next search result, or false.
         * STUB
         * FIXME: refactor as iterator, so we could use nicer interfaces.
+        * @deprecated since 1.32; Use self::extractResults()
         * @return SearchResult|false
         */
        function next() {
@@ -181,6 +182,7 @@ class SearchResultSet {
 
        /**
         * Rewind result set back to beginning
+        * @deprecated since 1.32; Use self::extractResults()
         */
        function rewind() {
        }
index eb383ef..1dc37d2 100644 (file)
@@ -156,7 +156,7 @@ class SearchSqlite extends SearchDatabase {
         * @param string $term Raw search term
         * @return SqlSearchResultSet
         */
-       function searchText( $term ) {
+       protected function doSearchText( $term ) {
                return $this->searchInternal( $term, true );
        }
 
@@ -166,7 +166,7 @@ class SearchSqlite extends SearchDatabase {
         * @param string $term Raw search term
         * @return SqlSearchResultSet
         */
-       function searchTitle( $term ) {
+       protected function doSearchTitle( $term ) {
                return $this->searchInternal( $term, false );
        }