dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Document SearchDatabase::doSearchTextInDB to return null"
[lhc/web/wiklou.git]
/
includes
/
search
/
SearchOracle.php
diff --git
a/includes/search/SearchOracle.php
b/includes/search/SearchOracle.php
index
0cbb41c
..
d0869bc
100644
(file)
--- 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
* 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 == '' ) {
*/
protected function doSearchTextInDB( $term ) {
if ( $term == '' ) {
- return n
ew SqlSearchResultSet( false, '' )
;
+ return n
ull
;
}
}
- $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 );
}
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
* 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 == '' ) {
*/
protected function doSearchTitleInDB( $term ) {
if ( $term == '' ) {
- return n
ew SqlSearchResultSet( false, '' )
;
+ return n
ull
;
}
}
- $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 );
}
return new SqlSearchResultSet( $resultSet, $this->searchTerms );
}
@@
-101,7
+103,8
@@
class SearchOracle extends SearchDatabase {
if ( $this->namespaces === [] ) {
$namespaces = '0';
} else {
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 . ')';
}
}
return 'AND page_namespace IN (' . $namespaces . ')';
}
@@
-114,7
+117,9
@@
class SearchOracle extends SearchDatabase {
* @return string
*/
private function queryLimit( $sql ) {
* @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 );
*/
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;
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 );
$field = $this->getIndexField( $fulltext );
+
return " CONTAINS($field, $searchon, 1) > 0 ";
}
return " CONTAINS($field, $searchon, 1) > 0 ";
}
@@
-230,7
+240,7
@@
class SearchOracle extends SearchDatabase {
* @param string $text
*/
function update( $id, $title, $text ) {
* @param string $text
*/
function update( $id, $title, $text ) {
- $dbw =
wfGetDB
( DB_MASTER );
+ $dbw =
$this->lb->getMaintenanceConnectionRef
( DB_MASTER );
$dbw->replace( 'searchindex',
[ 'si_page' ],
[
$dbw->replace( 'searchindex',
[ 'si_page' ],
[
@@
-258,8
+268,7
@@
class SearchOracle extends SearchDatabase {
* @param string $title
*/
function updateTitle( $id, $title ) {
* @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 ],
$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;
$searchChars = parent::legalSearchChars( $type );
if ( $type === self::CHARS_ALL ) {
$searchChars = "\"" . $searchChars;