From bc2ffb28d6ce667e6a6127e07e203a97150228c8 Mon Sep 17 00:00:00 2001 From: Liangent Date: Thu, 5 Jun 2014 13:00:52 +0000 Subject: [PATCH] Load previous tags in ChangeTags::addTags() from DB_MASTER This fixes a bug in mobile [1] that the tag added by MobileApp gets overwritten by MobileFrontend, where both use ChangeTags::addTags(), and MobileFrontend is registered (thus called) after MobileApp. [1] http://lists.wikimedia.org/pipermail/mobile-l/2014-June/007260.html Change-Id: Ie47649ef45f9eebdfeae73a0698ea5d21b150b56 --- includes/ChangeTags.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/ChangeTags.php b/includes/ChangeTags.php index d3dd51aa54..7e19164443 100644 --- a/includes/ChangeTags.php +++ b/includes/ChangeTags.php @@ -146,7 +146,10 @@ class ChangeTags { ); ## Update the summary row. - $prevTags = $dbr->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ ); + $dbw = wfGetDB( DB_MASTER ); + // $prevTags can be out of date on slaves, especially when addTags is called consecutively, + // causing loss of tags added recently in tag_summary table. + $prevTags = $dbw->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ ); $prevTags = $prevTags ? $prevTags : ''; $prevTags = array_filter( explode( ',', $prevTags ) ); $newTags = array_unique( array_merge( $prevTags, $tags ) ); @@ -158,7 +161,6 @@ class ChangeTags { return false; } - $dbw = wfGetDB( DB_MASTER ); $dbw->replace( 'tag_summary', array( 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ), -- 2.20.1