From: Tim Starling Date: Wed, 11 Dec 2013 00:48:47 +0000 (+1100) Subject: Send QueryPage recache queries to a separate query group X-Git-Tag: 1.31.0-rc.0~17666^2~1 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=758707593a885a177dd1cd4c5b9a909746b9a345;p=lhc%2Fweb%2Fwiklou.git Send QueryPage recache queries to a separate query group This essential feature was broken 3 years ago, in r78786. The group connection was being used only for a call to the archaic Database::fetchObject(). Change-Id: Ia4c76c88ecc77eb663a535b0625a1509882a35c7 --- diff --git a/includes/QueryPage.php b/includes/QueryPage.php index b8e4e60c48..ff505b1509 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -295,8 +295,7 @@ abstract class QueryPage extends SpecialPage { $fname = get_class( $this ) . '::recache'; $dbw = wfGetDB( DB_MASTER ); - $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), __METHOD__, 'vslow' ) ); - if ( !$dbw || !$dbr ) { + if ( !$dbw ) { return false; } @@ -310,7 +309,7 @@ abstract class QueryPage extends SpecialPage { $num = $res->numRows(); # Fetch results $vals = array(); - while ( $res && $row = $dbr->fetchObject( $res ) ) { + foreach ( $res as $row ) { if ( isset( $row->value ) ) { if ( $this->usesTimestamps() ) { $value = wfTimestamp( TS_UNIX, @@ -348,6 +347,13 @@ abstract class QueryPage extends SpecialPage { return $num; } + /** + * Get a DB connection to be used for slow recache queries + */ + function getRecacheDB() { + return wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) ); + } + /** * Run the query and return the result * @param int|bool $limit Numerical limit or false for no limit @@ -357,7 +363,7 @@ abstract class QueryPage extends SpecialPage { */ function reallyDoQuery( $limit, $offset = false ) { $fname = get_class( $this ) . "::reallyDoQuery"; - $dbr = wfGetDB( DB_SLAVE ); + $dbr = $this->getRecacheDB(); $query = $this->getQueryInfo(); $order = $this->getOrderFields();