From: Tim Starling Date: Fri, 7 Jun 2013 00:31:37 +0000 (+1000) Subject: Avoid master queries in Revision::newFromTitle(..., Revision::READ_NORMAL) X-Git-Tag: 1.31.0-rc.0~18433 X-Git-Url: https://git.cyclocoop.org/%27.%24link.%27?a=commitdiff_plain;h=e6b1baf240b8323ab092ce9be85050bf63336049;p=lhc%2Fweb%2Fwiklou.git Avoid master queries in Revision::newFromTitle(..., Revision::READ_NORMAL) The fallback to master makes sense in Revision::newFromId(), since a revision ID known to exist by some other means might be present in the master but not in the slave. But it doesn't make sense for Revision::newFromTitle(), where by far the most common cause of this case being hit is the page being nonexistent. Change-Id: I41189fcde1b8065ac134982241376d63b78732a1 --- diff --git a/includes/Revision.php b/includes/Revision.php index 305c8ffa87..233eac01bf 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -116,11 +116,13 @@ class Revision implements IDBAccessObject { if ( $id ) { // Use the specified ID $conds['rev_id'] = $id; + return self::newFromConds( $conds, (int)$flags ); } else { // Use a join to get the latest revision $conds[] = 'rev_id=page_latest'; + $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_SLAVE ); + return self::loadFromConds( $db, $conds, $flags ); } - return self::newFromConds( $conds, (int)$flags ); } /**