X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fsearch%2FSearchOracle.php;h=6dad3424b138a070c4df8cc6ee3d7898bcebf0cc;hb=d19826aa35b206847a568a4b2c1c9ffaa615fca5;hp=348da79a9fd1355ec31c1df4cd2773c285aaccfd;hpb=ec9002258c8a0264cb2d92df6a216e9fa11d3462;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 348da79a9f..8bcd78fa66 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. @@ -69,10 +69,7 @@ class SearchOracle extends SearchDatabase { return new SqlSearchResultSet( false, '' ); } - $resultSet = $this->db->resultObject( - $this->db->query( $this->getQuery( $this->filter( $term ), true ) ) - ); - + $resultSet = $this->db->query( $this->getQuery( $this->filter( $term ), true ) ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } @@ -87,10 +84,7 @@ class SearchOracle extends SearchDatabase { return new SqlSearchResultSet( false, '' ); } - $resultSet = $this->db->resultObject( - $this->db->query( $this->getQuery( $this->filter( $term ), false ) ) - ); - + $resultSet = $this->db->query( $this->getQuery( $this->filter( $term ), false ) ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } @@ -180,11 +174,11 @@ class SearchOracle extends SearchDatabase { */ 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 ) ) { @@ -197,8 +191,7 @@ class SearchOracle extends SearchDatabase { foreach ( $temp_terms as $t ) { $searchon .= ( $terms[1] == '-' ? ' ~' : ' & ' ) . $this->escapeTerm( $t ); } - } - else { + } else { $searchon .= ( $terms[1] == '-' ? ' ~' : ' & ' ) . $this->escapeTerm( $terms[2] ); } if ( !empty( $terms[3] ) ) { @@ -238,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 @@ -267,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; } }