X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fsearch%2FSearchOracle.php;h=d0869bc7d7a4b9cd71857fd979f0412ac74a1a28;hb=f585244a778ed712859f48383472c24f105b1b4e;hp=0cbb41c4711b17e4f6d05506b0239312f3ff170d;hpb=f374b21f62aa36ce238c485eaa36d728e84e9954;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 0cbb41c471..d0869bc7d7 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -64,14 +64,15 @@ class SearchOracle extends SearchDatabase { * Perform a full text search query and return a result set. * * @param string $term Raw search term - * @return SqlSearchResultSet + * @return SqlSearchResultSet|null */ protected function doSearchTextInDB( $term ) { if ( $term == '' ) { - return new SqlSearchResultSet( false, '' ); + return null; } - $resultSet = $this->db->query( $this->getQuery( $this->filter( $term ), true ) ); + $dbr = $this->lb->getConnectionRef( DB_REPLICA ); + $resultSet = $dbr->query( $this->getQuery( $this->filter( $term ), true ) ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } @@ -79,14 +80,15 @@ class SearchOracle extends SearchDatabase { * Perform a title-only search query and return a result set. * * @param string $term Raw search term - * @return SqlSearchResultSet + * @return SqlSearchResultSet|null */ protected function doSearchTitleInDB( $term ) { if ( $term == '' ) { - return new SqlSearchResultSet( false, '' ); + return null; } - $resultSet = $this->db->query( $this->getQuery( $this->filter( $term ), false ) ); + $dbr = $this->lb->getConnectionRef( DB_REPLICA ); + $resultSet = $dbr->query( $this->getQuery( $this->filter( $term ), false ) ); return new SqlSearchResultSet( $resultSet, $this->searchTerms ); } @@ -101,7 +103,8 @@ class SearchOracle extends SearchDatabase { if ( $this->namespaces === [] ) { $namespaces = '0'; } else { - $namespaces = $this->db->makeList( $this->namespaces ); + $dbr = $this->lb->getConnectionRef( DB_REPLICA ); + $namespaces = $dbr->makeList( $this->namespaces ); } return 'AND page_namespace IN (' . $namespaces . ')'; } @@ -114,7 +117,9 @@ class SearchOracle extends SearchDatabase { * @return string */ private function queryLimit( $sql ) { - return $this->db->limitResult( $sql, $this->limit, $this->offset ); + $dbr = $this->lb->getConnectionRef( DB_REPLICA ); + + return $dbr->limitResult( $sql, $this->limit, $this->offset ); } /** @@ -160,8 +165,11 @@ class SearchOracle extends SearchDatabase { */ function queryMain( $filteredTerm, $fulltext ) { $match = $this->parseQuery( $filteredTerm, $fulltext ); - $page = $this->db->tableName( 'page' ); - $searchindex = $this->db->tableName( 'searchindex' ); + + $dbr = $this->lb->getMaintenanceConnectionRef( DB_REPLICA ); + $page = $dbr->tableName( 'page' ); + $searchindex = $dbr->tableName( 'searchindex' ); + return 'SELECT page_id, page_namespace, page_title ' . "FROM $page,$searchindex " . 'WHERE page_id=si_page AND ' . $match; @@ -208,8 +216,10 @@ class SearchOracle extends SearchDatabase { } } - $searchon = $this->db->addQuotes( ltrim( $searchon, ' &' ) ); + $dbr = $this->lb->getConnectionRef( DB_REPLICA ); + $searchon = $dbr->addQuotes( ltrim( $searchon, ' &' ) ); $field = $this->getIndexField( $fulltext ); + return " CONTAINS($field, $searchon, 1) > 0 "; } @@ -230,7 +240,7 @@ class SearchOracle extends SearchDatabase { * @param string $text */ function update( $id, $title, $text ) { - $dbw = wfGetDB( DB_MASTER ); + $dbw = $this->lb->getMaintenanceConnectionRef( DB_MASTER ); $dbw->replace( 'searchindex', [ 'si_page' ], [ @@ -258,8 +268,7 @@ class SearchOracle extends SearchDatabase { * @param string $title */ function updateTitle( $id, $title ) { - $dbw = wfGetDB( DB_MASTER ); - + $dbw = $this->lb->getConnectionRef( DB_MASTER ); $dbw->update( 'searchindex', [ 'si_title' => $title ], [ 'si_page' => $id ], @@ -267,7 +276,7 @@ class SearchOracle extends SearchDatabase { [] ); } - public static function legalSearchChars( $type = self::CHARS_ALL ) { + public function legalSearchChars( $type = self::CHARS_ALL ) { $searchChars = parent::legalSearchChars( $type ); if ( $type === self::CHARS_ALL ) { $searchChars = "\"" . $searchChars;