Change the default for wgThumbnailMinimumBucketDistance
[lhc/web/wiklou.git] / includes / ChangeTags.php
index d3dd51a..f51a5a8 100644 (file)
@@ -77,9 +77,9 @@ class ChangeTags {
         * Add tags to a change given its rc_id, rev_id and/or log_id
         *
         * @param string|array $tags Tags to add to the change
-        * @param int $rc_id rc_id of the change to add the tags to
-        * @param int $rev_id rev_id of the change to add the tags to
-        * @param int $log_id Log_id of the change to add the tags to
+        * @param int|null $rc_id rc_id of the change to add the tags to
+        * @param int|null $rev_id rev_id of the change to add the tags to
+        * @param int|null $log_id Log_id of the change to add the tags to
         * @param string $params params to put in the ct_params field of table 'change_tag'
         *
         * @throws MWException
@@ -101,21 +101,20 @@ class ChangeTags {
                                'specified when adding a tag to a change!' );
                }
 
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbw = wfGetDB( DB_MASTER );
 
                // Might as well look for rcids and so on.
                if ( !$rc_id ) {
                        // Info might be out of date, somewhat fractionally, on slave.
-                       $dbr = wfGetDB( DB_MASTER );
                        if ( $log_id ) {
-                               $rc_id = $dbr->selectField(
+                               $rc_id = $dbw->selectField(
                                        'recentchanges',
                                        'rc_id',
                                        array( 'rc_logid' => $log_id ),
                                        __METHOD__
                                );
                        } elseif ( $rev_id ) {
-                               $rc_id = $dbr->selectField(
+                               $rc_id = $dbw->selectField(
                                        'recentchanges',
                                        'rc_id',
                                        array( 'rc_this_oldid' => $rev_id ),
@@ -124,14 +123,13 @@ class ChangeTags {
                        }
                } elseif ( !$log_id && !$rev_id ) {
                        // Info might be out of date, somewhat fractionally, on slave.
-                       $dbr = wfGetDB( DB_MASTER );
-                       $log_id = $dbr->selectField(
+                       $log_id = $dbw->selectField(
                                'recentchanges',
                                'rc_logid',
                                array( 'rc_id' => $rc_id ),
                                __METHOD__
                        );
-                       $rev_id = $dbr->selectField(
+                       $rev_id = $dbw->selectField(
                                'recentchanges',
                                'rc_this_oldid',
                                array( 'rc_id' => $rc_id ),
@@ -145,8 +143,10 @@ class ChangeTags {
                        'ts_log_id' => $log_id )
                );
 
-               ## Update the summary row.
-               $prevTags = $dbr->selectField( 'tag_summary', 'ts_tags', $tsConds, __METHOD__ );
+               // Update the summary row.
+               // $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 +158,6 @@ class ChangeTags {
                        return false;
                }
 
-               $dbw = wfGetDB( DB_MASTER );
                $dbw->replace(
                        'tag_summary',
                        array( 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ),