r77109 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77108‎ | r77109 | r77110 >
Date:16:08, 22 November 2010
Author:platonides
Status:ok
Tags:
Comment:
Move storing of $db down to SearchEngine
Fixes the r76809 issue of SearchDbTest not being marked as requiring a Database.
Modified paths:
  • /trunk/extensions/SphinxSearch/SphinxMWSearch.php (modified) (history)
  • /trunk/phase3/includes/search/SearchEngine.php (modified) (history)
  • /trunk/phase3/includes/search/SearchIBM_DB2.php (modified) (history)
  • /trunk/phase3/includes/search/SearchMssql.php (modified) (history)
  • /trunk/phase3/includes/search/SearchMySQL.php (modified) (history)
  • /trunk/phase3/includes/search/SearchOracle.php (modified) (history)
  • /trunk/phase3/includes/search/SearchPostgres.php (modified) (history)
  • /trunk/phase3/includes/search/SearchSqlite.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/search/SearchEngine.php
@@ -22,6 +22,14 @@
2323 var $namespaces = array( NS_MAIN );
2424 var $showRedirects = false;
2525
 26+ function __construct($db = null) {
 27+ if ( $db ) {
 28+ $this->db = $db;
 29+ } else {
 30+ $this->db = wfGetDB( DB_SLAVE );
 31+ }
 32+ }
 33+
2634 /**
2735 * Perform a full text search query and return a result set.
2836 * If title searches are not supported or disabled, return null.
@@ -383,10 +391,11 @@
384392 */
385393 public static function create() {
386394 global $wgSearchType;
387 - $dbr = wfGetDB( DB_SLAVE );
 395+ $dbr = null;
388396 if ( $wgSearchType ) {
389397 $class = $wgSearchType;
390398 } else {
 399+ $dbr = wfGetDB( DB_SLAVE );
391400 $class = $dbr->getSearchEngine();
392401 }
393402 $search = new $class( $dbr );
Index: trunk/phase3/includes/search/SearchMySQL.php
@@ -32,9 +32,12 @@
3333 var $strictMatching = true;
3434 static $mMinSearchLength;
3535
36 - /** @todo document */
 36+ /**
 37+ * Creates an instance of this class
 38+ * @param $db DatabaseMysql: database object
 39+ */
3740 function __construct( $db ) {
38 - $this->db = $db;
 41+ parent::__construct( $db );
3942 }
4043
4144 /**
@@ -410,4 +413,4 @@
411414 function getTotalHits() {
412415 return $this->mTotalHits;
413416 }
414 -}
\ No newline at end of file
 417+}
Index: trunk/phase3/includes/search/SearchOracle.php
@@ -56,9 +56,13 @@
5757 'TRSYN' => 1,
5858 'TT' => 1,
5959 'WITHIN' => 1);
60 -
 60+
 61+ /**
 62+ * Creates an instance of this class
 63+ * @param $db DatabasePostgres: database object
 64+ */
6165 function __construct($db) {
62 - $this->db = $db;
 66+ parent::__construct( $db );
6367 }
6468
6569 /**
Index: trunk/phase3/includes/search/SearchPostgres.php
@@ -29,9 +29,12 @@
3030 * @ingroup Search
3131 */
3232 class SearchPostgres extends SearchEngine {
33 -
 33+ /**
 34+ * Creates an instance of this class
 35+ * @param $db DatabaseSqlite: database object
 36+ */
3437 function __construct( $db ) {
35 - $this->db = $db;
 38+ parent::__construct( $db );
3639 }
3740
3841 /**
Index: trunk/phase3/includes/search/SearchIBM_DB2.php
@@ -29,8 +29,13 @@
3030 * @ingroup Search
3131 */
3232 class SearchIBM_DB2 extends SearchEngine {
 33+
 34+ /**
 35+ * Creates an instance of this class
 36+ * @param $db DatabaseIbm_db2: database object
 37+ */
3338 function __construct($db) {
34 - $this->db = $db;
 39+ parent::__construct( $db );
3540 }
3641
3742 /**
Index: trunk/phase3/includes/search/SearchMssql.php
@@ -27,8 +27,12 @@
2828 */
2929 class SearchMssql extends SearchEngine {
3030
 31+ /**
 32+ * Creates an instance of this class
 33+ * @param $db DatabaseMssql: database object
 34+ */
3135 function __construct( $db ) {
32 - $this->db = $db;
 36+ parent::__construct( $db );
3337 }
3438
3539 /**
Index: trunk/phase3/includes/search/SearchSqlite.php
@@ -31,7 +31,7 @@
3232 * @param $db DatabaseSqlite: database object
3333 */
3434 function __construct( $db ) {
35 - $this->db = $db;
 35+ parent::__construct( $db );
3636 }
3737
3838 /**
@@ -331,4 +331,4 @@
332332 function getTotalHits() {
333333 return $this->mTotalHits;
334334 }
335 -}
\ No newline at end of file
 335+}
Index: trunk/extensions/SphinxSearch/SphinxMWSearch.php
@@ -12,7 +12,7 @@
1313 * @author Svemir Brkic <svemir@deveblog.com>
1414 */
1515
16 - class SphinxMWSearch extends SearchEngine {
 16+class SphinxMWSearch extends SearchEngine {
1717
1818 var $categories = array();
1919 var $exc_categories = array();
@@ -20,7 +20,7 @@
2121 var $sphinx_client = null;
2222
2323 function __construct( $db ) {
24 - $this->db = $db;
 24+ parent::__construct( $db );
2525 }
2626
2727 /**
@@ -382,4 +382,4 @@
383383 return $ret;
384384 }
385385
386 -}
\ No newline at end of file
 386+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r96401emulate Wikipedia search where ~ prefix prevents automatic redirect...svemir03:06, 7 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r76809Follow-up r76805: removed outdated comment, introduced new group "Search"maxsem16:54, 16 November 2010

Status & tagging log