* 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
'specified when adding a tag to a change!' );
}
+ $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 ),
}
} 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 ),
'ts_log_id' => $log_id )
);
- ## Update the summary row.
- $dbw = wfGetDB( DB_MASTER );
+ // 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__ );