From: Liangent Date: Thu, 5 Jun 2014 13:00:52 +0000 (+0000) Subject: Load previous tags in ChangeTags::addTags() from DB_MASTER X-Git-Tag: 1.31.0-rc.0~15459^2 X-Git-Url: http://git.cyclocoop.org/wiki/Target_page?a=commitdiff_plain;h=bc2ffb28d6ce667e6a6127e07e203a97150228c8;p=lhc%2Fweb%2Fwiklou.git 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 --- 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' ),