From: Aaron Schulz Date: Thu, 28 Apr 2016 21:26:38 +0000 (-0700) Subject: Avoid master queries in getAutoDeleteReason() X-Git-Tag: 1.31.0-rc.0~7142^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%22id_auteur=%24connect_id_auteur%22%29%20.%20%22?a=commitdiff_plain;h=bd863cc1f30b97fea1b13c030ed72b85ddc97afd;p=lhc%2Fweb%2Fwiklou.git Avoid master queries in getAutoDeleteReason() This largely used the slaves anyway, but not for certain bits. Bug: T92357 Change-Id: I909a14b25a959ee28960aa7aa3d799c5f10988d1 --- diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 7430caf8b4..f3d678108f 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -892,7 +892,7 @@ abstract class ContentHandler { * have it / want it. */ public function getAutoDeleteReason( Title $title, &$hasHistory ) { - $dbw = wfGetDB( DB_MASTER ); + $dbr = wfGetDB( DB_SLAVE ); // Get the last revision $rev = Revision::newFromTitle( $title ); @@ -922,10 +922,10 @@ abstract class ContentHandler { // Find out if there was only one contributor // Only scan the last 20 revisions - $res = $dbw->select( 'revision', 'rev_user_text', + $res = $dbr->select( 'revision', 'rev_user_text', [ 'rev_page' => $title->getArticleID(), - $dbw->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' + $dbr->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' ], __METHOD__, [ 'LIMIT' => 20 ] @@ -937,7 +937,7 @@ abstract class ContentHandler { } $hasHistory = ( $res->numRows() > 1 ); - $row = $dbw->fetchObject( $res ); + $row = $dbr->fetchObject( $res ); if ( $row ) { // $row is false if the only contributor is hidden $onlyAuthor = $row->rev_user_text;