From 0824579606fe2f5920d2aeb5ab7d1a4bc4838007 Mon Sep 17 00:00:00 2001 From: David Causse Date: Wed, 9 May 2018 11:56:27 +0200 Subject: [PATCH] Make internal search methods private for db implementations Change-Id: I622f1b35e27de7918e32c4ddd74ceb4e257c5b02 --- includes/search/SearchMssql.php | 12 +++++------- includes/search/SearchMySQL.php | 12 ++++++------ includes/search/SearchOracle.php | 10 +++++----- includes/search/SearchPostgres.php | 4 ++-- includes/search/SearchSqlite.php | 16 ++++++++-------- 5 files changed, 26 insertions(+), 28 deletions(-) diff --git a/includes/search/SearchMssql.php b/includes/search/SearchMssql.php index 57ca06e39f..3b55b89039 100644 --- a/includes/search/SearchMssql.php +++ b/includes/search/SearchMssql.php @@ -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 = []; diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index c98f7e337c..3ae8837953 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -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 = [ diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 8bcd78fa66..f38d0dbc1d 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -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 = []; diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index 5a50b176e9..f660e7ab28 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -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 ); diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index af29212ba1..eb383ef23d 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -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' ); -- 2.20.1