From bd863cc1f30b97fea1b13c030ed72b85ddc97afd Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Thu, 28 Apr 2016 14:26:38 -0700 Subject: [PATCH] Avoid master queries in getAutoDeleteReason() This largely used the slaves anyway, but not for certain bits. Bug: T92357 Change-Id: I909a14b25a959ee28960aa7aa3d799c5f10988d1 --- includes/content/ContentHandler.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; -- 2.20.1