X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchOracle.php;h=2e6cb84ca6a393281fefef8f122019b5cec0968b;hb=9d673e0bc6ae8c87ccf6a4486501c759f1c5b2ae;hp=6dad3424b138a070c4df8cc6ee3d7898bcebf0cc;hpb=6da98ee84b844c9fba0d6c7fa76d8fc50bf2abbc;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 6dad3424b1..6d7e988663 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -29,7 +29,7 @@ * @ingroup Search */ class SearchOracle extends SearchDatabase { - private $reservedWords = array( + private $reservedWords = [ 'ABOUT' => 1, 'ACCUM' => 1, 'AND' => 1, @@ -56,7 +56,7 @@ class SearchOracle extends SearchDatabase { 'TRSYN' => 1, 'TT' => 1, 'WITHIN' => 1, - ); + ]; /** * Perform a full text search query and return a result set. @@ -64,7 +64,7 @@ class SearchOracle extends SearchDatabase { * @param string $term Raw search term * @return SqlSearchResultSet */ - function searchText( $term ) { + protected function doSearchTextInDB( $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 doSearchTitleInDB( $term ) { if ( $term == '' ) { return new SqlSearchResultSet( false, '' ); } @@ -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,13 +172,13 @@ class SearchOracle extends SearchDatabase { * @param bool $fulltext * @return string */ - function parseQuery( $filteredText, $fulltext ) { + private function parseQuery( $filteredText, $fulltext ) { global $wgContLang; - $lc = $this->legalSearchChars(); - $this->searchTerms = array(); + $lc = $this->legalSearchChars( self::CHARS_NO_SYNTAX ); + $this->searchTerms = []; # @todo FIXME: This doesn't handle parenthetical expressions. - $m = array(); + $m = []; $searchon = ''; if ( preg_match_all( '/([-+<>~]?)(([' . $lc . ']+)(\*?)|"[^"]*")/', $filteredText, $m, PREG_SET_ORDER ) ) { @@ -231,12 +231,12 @@ class SearchOracle extends SearchDatabase { function update( $id, $title, $text ) { $dbw = wfGetDB( DB_MASTER ); $dbw->replace( 'searchindex', - array( 'si_page' ), - array( + [ 'si_page' ], + [ 'si_page' => $id, 'si_title' => $title, 'si_text' => $text - ), 'SearchOracle::update' ); + ], 'SearchOracle::update' ); // Sync the index // We need to specify the DB name (i.e. user/schema) here so that @@ -260,13 +260,17 @@ class SearchOracle extends SearchDatabase { $dbw = wfGetDB( DB_MASTER ); $dbw->update( 'searchindex', - array( 'si_title' => $title ), - array( 'si_page' => $id ), + [ 'si_title' => $title ], + [ 'si_page' => $id ], 'SearchOracle::updateTitle', - array() ); + [] ); } - public static function legalSearchChars() { - return "\"" . parent::legalSearchChars(); + public static function legalSearchChars( $type = self::CHARS_ALL ) { + $searchChars = parent::legalSearchChars( $type ); + if ( $type === self::CHARS_ALL ) { + $searchChars = "\"" . $searchChars; + } + return $searchChars; } }