Make internal search methods private for db implementations
authorDavid Causse <dcausse@wikimedia.org>
Wed, 9 May 2018 09:56:27 +0000 (11:56 +0200)
committerDavid Causse <dcausse@wikimedia.org>
Wed, 9 May 2018 09:56:27 +0000 (11:56 +0200)
Change-Id: I622f1b35e27de7918e32c4ddd74ceb4e257c5b02

includes/search/SearchMssql.php
includes/search/SearchMySQL.php
includes/search/SearchOracle.php
includes/search/SearchPostgres.php
includes/search/SearchSqlite.php

index 57ca06e..3b55b89 100644 (file)
@@ -54,9 +54,8 @@ class SearchMssql extends SearchDatabase {
         * Return a partial WHERE clause to limit the search to the given namespaces
         *
         * @return string
-        * @private
         */
-       function queryNamespaces() {
+       private function queryNamespaces() {
                $namespaces = implode( ',', $this->namespaces );
                if ( $namespaces == '' ) {
                        $namespaces = '0';
@@ -71,7 +70,7 @@ class SearchMssql extends SearchDatabase {
         *
         * @return string
         */
-       function queryLimit( $sql ) {
+       private function queryLimit( $sql ) {
                return $this->db->limitResult( $sql, $this->limit, $this->offset );
        }
 
@@ -95,7 +94,7 @@ class SearchMssql extends SearchDatabase {
         * @param bool $fulltext
         * @return string
         */
-       function getQuery( $filteredTerm, $fulltext ) {
+       private function getQuery( $filteredTerm, $fulltext ) {
                return $this->queryLimit( $this->queryMain( $filteredTerm, $fulltext ) . ' ' .
                        $this->queryNamespaces() . ' ' .
                        $this->queryRanking( $filteredTerm, $fulltext ) . ' ' );
@@ -117,9 +116,8 @@ class SearchMssql extends SearchDatabase {
         * @param string $filteredTerm
         * @param bool $fulltext
         * @return string
-        * @private
         */
-       function queryMain( $filteredTerm, $fulltext ) {
+       private function queryMain( $filteredTerm, $fulltext ) {
                $match = $this->parseQuery( $filteredTerm, $fulltext );
                $page = $this->db->tableName( 'page' );
                $searchindex = $this->db->tableName( 'searchindex' );
@@ -134,7 +132,7 @@ class SearchMssql extends SearchDatabase {
         * @param bool $fulltext
         * @return string
         */
-       function parseQuery( $filteredText, $fulltext ) {
+       private function parseQuery( $filteredText, $fulltext ) {
                global $wgContLang;
                $lc = $this->legalSearchChars( self::CHARS_NO_SYNTAX );
                $this->searchTerms = [];
index c98f7e3..3ae8837 100644 (file)
@@ -42,7 +42,7 @@ class SearchMySQL extends SearchDatabase {
         *
         * @return array
         */
-       function parseQuery( $filteredText, $fulltext ) {
+       private function parseQuery( $filteredText, $fulltext ) {
                global $wgContLang;
 
                $lc = $this->legalSearchChars( self::CHARS_NO_SYNTAX ); // Minus syntax chars (" and *)
@@ -133,7 +133,7 @@ class SearchMySQL extends SearchDatabase {
                ];
        }
 
-       function regexTerm( $string, $wildcard ) {
+       private function regexTerm( $string, $wildcard ) {
                global $wgContLang;
 
                $regex = preg_quote( $string, '/' );
@@ -264,7 +264,7 @@ class SearchMySQL extends SearchDatabase {
         * @return array
         * @since 1.18 (changed)
         */
-       function getQuery( $filteredTerm, $fulltext ) {
+       private function getQuery( $filteredTerm, $fulltext ) {
                $query = [
                        'tables' => [],
                        'fields' => [],
@@ -286,7 +286,7 @@ class SearchMySQL extends SearchDatabase {
         * @param bool $fulltext
         * @return string
         */
-       function getIndexField( $fulltext ) {
+       private function getIndexField( $fulltext ) {
                return $fulltext ? 'si_text' : 'si_title';
        }
 
@@ -298,7 +298,7 @@ class SearchMySQL extends SearchDatabase {
         * @param bool $fulltext
         * @since 1.18 (changed)
         */
-       function queryMain( &$query, $filteredTerm, $fulltext ) {
+       private function queryMain( &$query, $filteredTerm, $fulltext ) {
                $match = $this->parseQuery( $filteredTerm, $fulltext );
                $query['tables'][] = 'page';
                $query['tables'][] = 'searchindex';
@@ -316,7 +316,7 @@ class SearchMySQL extends SearchDatabase {
         * @param bool $fulltext
         * @return array
         */
-       function getCountQuery( $filteredTerm, $fulltext ) {
+       private function getCountQuery( $filteredTerm, $fulltext ) {
                $match = $this->parseQuery( $filteredTerm, $fulltext );
 
                $query = [
index 8bcd78f..f38d0db 100644 (file)
@@ -92,7 +92,7 @@ class SearchOracle extends SearchDatabase {
         * Return a partial WHERE clause to limit the search to the given namespaces
         * @return string
         */
-       function queryNamespaces() {
+       private function queryNamespaces() {
                if ( is_null( $this->namespaces ) ) {
                        return '';
                }
@@ -111,7 +111,7 @@ class SearchOracle extends SearchDatabase {
         *
         * @return string
         */
-       function queryLimit( $sql ) {
+       private function queryLimit( $sql ) {
                return $this->db->limitResult( $sql, $this->limit, $this->offset );
        }
 
@@ -134,7 +134,7 @@ class SearchOracle extends SearchDatabase {
         * @param bool $fulltext
         * @return string
         */
-       function getQuery( $filteredTerm, $fulltext ) {
+       private function getQuery( $filteredTerm, $fulltext ) {
                return $this->queryLimit( $this->queryMain( $filteredTerm, $fulltext ) . ' ' .
                        $this->queryNamespaces() . ' ' .
                        $this->queryRanking( $filteredTerm, $fulltext ) . ' ' );
@@ -145,7 +145,7 @@ class SearchOracle extends SearchDatabase {
         * @param bool $fulltext
         * @return string
         */
-       function getIndexField( $fulltext ) {
+       private function getIndexField( $fulltext ) {
                return $fulltext ? 'si_text' : 'si_title';
        }
 
@@ -172,7 +172,7 @@ class SearchOracle extends SearchDatabase {
         * @param bool $fulltext
         * @return string
         */
-       function parseQuery( $filteredText, $fulltext ) {
+       private function parseQuery( $filteredText, $fulltext ) {
                global $wgContLang;
                $lc = $this->legalSearchChars( self::CHARS_NO_SYNTAX );
                $this->searchTerms = [];
index 5a50b17..f660e7a 100644 (file)
@@ -61,7 +61,7 @@ class SearchPostgres extends SearchDatabase {
         *
         * @return string
         */
-       function parseQuery( $term ) {
+       private function parseQuery( $term ) {
                wfDebug( "parseQuery received: $term \n" );
 
                # # No backslashes allowed
@@ -123,7 +123,7 @@ class SearchPostgres extends SearchDatabase {
         * @param string $colname
         * @return string
         */
-       function searchQuery( $term, $fulltext, $colname ) {
+       private function searchQuery( $term, $fulltext, $colname ) {
                # Get the SQL fragment for the given term
                $searchstring = $this->parseQuery( $term );
 
index af29212..eb383ef 100644 (file)
@@ -42,7 +42,7 @@ class SearchSqlite extends SearchDatabase {
         * @param bool $fulltext
         * @return string
         */
-       function parseQuery( $filteredText, $fulltext ) {
+       private function parseQuery( $filteredText, $fulltext ) {
                global $wgContLang;
                $lc = $this->legalSearchChars( self::CHARS_NO_SYNTAX ); // Minus syntax chars (" and *)
                $searchon = '';
@@ -122,7 +122,7 @@ class SearchSqlite extends SearchDatabase {
                return " $field MATCH $searchon ";
        }
 
-       function regexTerm( $string, $wildcard ) {
+       private function regexTerm( $string, $wildcard ) {
                global $wgContLang;
 
                $regex = preg_quote( $string, '/' );
@@ -195,7 +195,7 @@ class SearchSqlite extends SearchDatabase {
         * Return a partial WHERE clause to limit the search to the given namespaces
         * @return string
         */
-       function queryNamespaces() {
+       private function queryNamespaces() {
                if ( is_null( $this->namespaces ) ) {
                        return '';  # search all
                }
@@ -212,7 +212,7 @@ class SearchSqlite extends SearchDatabase {
         * @param string $sql
         * @return string
         */
-       function limitResult( $sql ) {
+       private function limitResult( $sql ) {
                return $this->db->limitResult( $sql, $this->limit, $this->offset );
        }
 
@@ -223,7 +223,7 @@ class SearchSqlite extends SearchDatabase {
         * @param bool $fulltext
         * @return string
         */
-       function getQuery( $filteredTerm, $fulltext ) {
+       private function getQuery( $filteredTerm, $fulltext ) {
                return $this->limitResult(
                        $this->queryMain( $filteredTerm, $fulltext ) . ' ' .
                        $this->queryNamespaces()
@@ -235,7 +235,7 @@ class SearchSqlite extends SearchDatabase {
         * @param bool $fulltext
         * @return string
         */
-       function getIndexField( $fulltext ) {
+       private function getIndexField( $fulltext ) {
                return $fulltext ? 'si_text' : 'si_title';
        }
 
@@ -246,7 +246,7 @@ class SearchSqlite extends SearchDatabase {
         * @param bool $fulltext
         * @return string
         */
-       function queryMain( $filteredTerm, $fulltext ) {
+       private function queryMain( $filteredTerm, $fulltext ) {
                $match = $this->parseQuery( $filteredTerm, $fulltext );
                $page = $this->db->tableName( 'page' );
                $searchindex = $this->db->tableName( 'searchindex' );
@@ -255,7 +255,7 @@ class SearchSqlite extends SearchDatabase {
                        "WHERE page_id=$searchindex.rowid AND $match";
        }
 
-       function getCountQuery( $filteredTerm, $fulltext ) {
+       private function getCountQuery( $filteredTerm, $fulltext ) {
                $match = $this->parseQuery( $filteredTerm, $fulltext );
                $page = $this->db->tableName( 'page' );
                $searchindex = $this->db->tableName( 'searchindex' );