X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22brouteur%22%2C%28%24id_rubrique%20?a=blobdiff_plain;f=includes%2Fchangetags%2FChangeTags.php;h=76dd754debd2f885f0a869233b1f5efd76ad133b;hb=fcf58d766db9228a4c4e79c74a0fe1b9340a385d;hp=15911bdc62626ed58c544e5c9ea5d51998fd235c;hpb=a78a3f28a21f6e8e7886e0cf1c62b423503b5d28;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 15911bdc62..76dd754deb 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -124,14 +124,16 @@ class ChangeTags { * @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]; } @@ -154,6 +156,9 @@ class ChangeTags { * 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 @@ -162,9 +167,9 @@ class ChangeTags { * * @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... @@ -284,6 +289,10 @@ class ChangeTags { } self::purgeTagUsageCache(); + + Hooks::run( 'ChangeTagsAfterUpdateTags', [ $tagsToAdd, $tagsToRemove, $prevTags, + $rc_id, $rev_id, $log_id, $params, $rc, $user ] ); + return [ $tagsToAdd, $tagsToRemove, $prevTags ]; } @@ -546,7 +555,7 @@ class ChangeTags { // 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)[ @@ -608,10 +617,10 @@ class ChangeTags { * 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 *