From: Tim Starling Date: Mon, 15 Aug 2005 13:06:33 +0000 (+0000) Subject: Always use reference assignment when taking the return value of wfGetDB(), or else... X-Git-Tag: 1.6.0~1960 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=28b2b4b2f5aadfbfc93b92945b401fb394ff7b06;p=lhc%2Fweb%2Fwiklou.git Always use reference assignment when taking the return value of wfGetDB(), or else annoying bugs which are difficult to track down will result. Example of correct usage: $dbr =& wfGetDB( DB_SLAVE ); --- diff --git a/includes/Article.php b/includes/Article.php index 6b562274ef..6515a27cac 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -486,7 +486,7 @@ class Article { * Get the database which should be used for reads */ function &getDB() { - $ret = wfGetDB( DB_MASTER ); + $ret =& wfGetDB( DB_MASTER ); return $ret; #if ( $this->mForUpdate ) { $ret =& wfGetDB( DB_MASTER ); @@ -854,7 +854,7 @@ class Article { function addTrackbacks() { global $wgOut, $wgUser; - $dbr = wfGetDB(DB_SLAVE); + $dbr =& wfGetDB(DB_SLAVE); $tbs = $dbr->select( /* FROM */ 'trackbacks', /* SELECT */ array('tb_id', 'tb_title', 'tb_url', 'tb_ex', 'tb_name'), @@ -900,7 +900,7 @@ class Article { return; } - $db = wfGetDB(DB_MASTER); + $db =& wfGetDB(DB_MASTER); $db->delete('trackbacks', array('tb_id' => $wgRequest->getInt('tbid'))); $wgTitle->invalidateCache(); $wgOut->addWikiText(wfMsg('trackbackdeleteok')); diff --git a/includes/LinkCache.php b/includes/LinkCache.php index 4eda8d20ca..a6df007184 100644 --- a/includes/LinkCache.php +++ b/includes/LinkCache.php @@ -388,7 +388,7 @@ class LinkBatch { // Construct query // This is very similar to Parser::replaceLinkHolders - $dbr = wfGetDB( DB_SLAVE ); + $dbr =& wfGetDB( DB_SLAVE ); $page = $dbr->tableName( 'page' ); $sql = "SELECT page_id, page_namespace, page_title FROM $page WHERE " . $this->constructSet( 'page', $dbr ); diff --git a/includes/Parser.php b/includes/Parser.php index 93ff1be2a6..cb09ffa1d8 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -2384,7 +2384,7 @@ class Parser } function fetchScaryTemplateMaybeFromCache($url) { - $dbr = wfGetDB(DB_SLAVE); + $dbr =& wfGetDB(DB_SLAVE); $obj = $dbr->selectRow('transcache', array('tc_time', 'tc_contents'), array('tc_url' => $url)); if ($obj) { @@ -2399,7 +2399,7 @@ class Parser if (!$text) return wfMsg('scarytranscludefailed', $url); - $dbw = wfGetDB(DB_MASTER); + $dbw =& wfGetDB(DB_MASTER); $dbw->replace('transcache', array(), array( 'tc_url' => $url, 'tc_time' => time(),