From a85f03a94fcc8e5f33296eae5a88d4dafc56b353 Mon Sep 17 00:00:00 2001 From: Platonides Date: Mon, 22 Nov 2010 16:08:12 +0000 Subject: [PATCH] Move storing of $db down to SearchEngine Fixes the r76809 issue of SearchDbTest not being marked as requiring a Database. --- includes/search/SearchEngine.php | 11 ++++++++++- includes/search/SearchIBM_DB2.php | 7 ++++++- includes/search/SearchMssql.php | 6 +++++- includes/search/SearchMySQL.php | 9 ++++++--- includes/search/SearchOracle.php | 8 ++++++-- includes/search/SearchPostgres.php | 7 +++++-- includes/search/SearchSqlite.php | 4 ++-- 7 files changed, 40 insertions(+), 12 deletions(-) diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index deba7740ce..984322d812 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -22,6 +22,14 @@ class SearchEngine { var $namespaces = array( NS_MAIN ); var $showRedirects = false; + function __construct($db = null) { + if ( $db ) { + $this->db = $db; + } else { + $this->db = wfGetDB( DB_SLAVE ); + } + } + /** * Perform a full text search query and return a result set. * If title searches are not supported or disabled, return null. @@ -383,10 +391,11 @@ class SearchEngine { */ public static function create() { global $wgSearchType; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = null; if ( $wgSearchType ) { $class = $wgSearchType; } else { + $dbr = wfGetDB( DB_SLAVE ); $class = $dbr->getSearchEngine(); } $search = new $class( $dbr ); diff --git a/includes/search/SearchIBM_DB2.php b/includes/search/SearchIBM_DB2.php index 97d48250e2..8cedd6f2d8 100644 --- a/includes/search/SearchIBM_DB2.php +++ b/includes/search/SearchIBM_DB2.php @@ -29,8 +29,13 @@ * @ingroup Search */ class SearchIBM_DB2 extends SearchEngine { + + /** + * Creates an instance of this class + * @param $db DatabaseIbm_db2: database object + */ function __construct($db) { - $this->db = $db; + parent::__construct( $db ); } /** diff --git a/includes/search/SearchMssql.php b/includes/search/SearchMssql.php index 4177775d5c..8b850fae36 100644 --- a/includes/search/SearchMssql.php +++ b/includes/search/SearchMssql.php @@ -27,8 +27,12 @@ */ class SearchMssql extends SearchEngine { + /** + * Creates an instance of this class + * @param $db DatabaseMssql: database object + */ function __construct( $db ) { - $this->db = $db; + parent::__construct( $db ); } /** diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index bb079c058e..b92682adf2 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -32,9 +32,12 @@ class SearchMySQL extends SearchEngine { var $strictMatching = true; static $mMinSearchLength; - /** @todo document */ + /** + * Creates an instance of this class + * @param $db DatabaseMysql: database object + */ function __construct( $db ) { - $this->db = $db; + parent::__construct( $db ); } /** @@ -410,4 +413,4 @@ class MySQLSearchResultSet extends SqlSearchResultSet { function getTotalHits() { return $this->mTotalHits; } -} \ No newline at end of file +} diff --git a/includes/search/SearchOracle.php b/includes/search/SearchOracle.php index 80fc118d99..bc5f6b51e7 100644 --- a/includes/search/SearchOracle.php +++ b/includes/search/SearchOracle.php @@ -56,9 +56,13 @@ class SearchOracle extends SearchEngine { 'TRSYN' => 1, 'TT' => 1, 'WITHIN' => 1); - + + /** + * Creates an instance of this class + * @param $db DatabasePostgres: database object + */ function __construct($db) { - $this->db = $db; + parent::__construct( $db ); } /** diff --git a/includes/search/SearchPostgres.php b/includes/search/SearchPostgres.php index c9a2c0bde0..8c9e2938e2 100644 --- a/includes/search/SearchPostgres.php +++ b/includes/search/SearchPostgres.php @@ -29,9 +29,12 @@ * @ingroup Search */ class SearchPostgres extends SearchEngine { - + /** + * Creates an instance of this class + * @param $db DatabaseSqlite: database object + */ function __construct( $db ) { - $this->db = $db; + parent::__construct( $db ); } /** diff --git a/includes/search/SearchSqlite.php b/includes/search/SearchSqlite.php index a7c09badf0..6accc31b29 100644 --- a/includes/search/SearchSqlite.php +++ b/includes/search/SearchSqlite.php @@ -31,7 +31,7 @@ class SearchSqlite extends SearchEngine { * @param $db DatabaseSqlite: database object */ function __construct( $db ) { - $this->db = $db; + parent::__construct( $db ); } /** @@ -331,4 +331,4 @@ class SqliteSearchResultSet extends SqlSearchResultSet { function getTotalHits() { return $this->mTotalHits; } -} \ No newline at end of file +} -- 2.20.1