* @param int|null $rev_id The rev_id of the change to add the tags to
* @param int|null $log_id The 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'
+ * @param RecentChange|null $rc Recent change, in case the tagging accompanies the action
+ * (this should normally be the case)
*
* @throws MWException
* @return bool False if no changes are made, otherwise true
*/
public static function addTags( $tags, $rc_id = null, $rev_id = null,
- $log_id = null, $params = null
+ $log_id = null, $params = null, RecentChange $rc = null
) {
- $result = self::updateTags( $tags, null, $rc_id, $rev_id, $log_id, $params );
+ $result = self::updateTags( $tags, null, $rc_id, $rev_id, $log_id, $params, $rc );
return (bool)$result[0];
}
* Pass a variable whose value is null if the log_id is not relevant or unknown.
* @param string $params Params to put in the ct_params field of table
* 'change_tag' when adding tags
+ * @param RecentChange|null $rc Recent change being tagged, in case the tagging accompanies
+ * the action
+ * @param User|null $user Tagging user, in case the tagging is subsequent to the tagged action
*
* @throws MWException When $rc_id, $rev_id and $log_id are all null
* @return array Index 0 is an array of tags actually added, index 1 is an
*
* @since 1.25
*/
- public static function updateTags(
- $tagsToAdd, $tagsToRemove,
- &$rc_id = null, &$rev_id = null, &$log_id = null, $params = null
+ public static function updateTags( $tagsToAdd, $tagsToRemove, &$rc_id = null,
+ &$rev_id = null, &$log_id = null, $params = null, RecentChange $rc = null,
+ User $user = null
) {
$tagsToAdd = array_filter( (array)$tagsToAdd ); // Make sure we're submitting all tags...
}
self::purgeTagUsageCache();
+
+ Hooks::run( 'ChangeTagsAfterUpdateTags', [ $tagsToAdd, $tagsToRemove, $prevTags,
+ $rc_id, $rev_id, $log_id, $params, $rc, $user ] );
+
return [ $tagsToAdd, $tagsToRemove, $prevTags ];
}
// do it!
list( $tagsAdded, $tagsRemoved, $initialTags ) = self::updateTags( $tagsToAdd,
- $tagsToRemove, $rc_id, $rev_id, $log_id, $params );
+ $tagsToRemove, $rc_id, $rev_id, $log_id, $params, null, $user );
if ( !$tagsAdded && !$tagsRemoved ) {
// no-op, don't log it
return Status::newGood( (object)[
* Handles selecting tags, and filtering.
* Needs $tables to be set up properly, so we can figure out which join conditions to use.
*
- * @param string|array $tables Table names, see DatabaseBase::select
- * @param string|array $fields Fields used in query, see DatabaseBase::select
- * @param string|array $conds Conditions used in query, see DatabaseBase::select
- * @param array $join_conds Join conditions, see DatabaseBase::select
+ * @param string|array $tables Table names, see Database::select
+ * @param string|array $fields Fields used in query, see Database::select
+ * @param string|array $conds Conditions used in query, see Database::select
+ * @param array $join_conds Join conditions, see Database::select
* @param array $options Options, see Database::select
* @param bool|string $filter_tag Tag to select on
*