Eranroz has uploaded a new change for review. https://gerrit.wikimedia.org/r/282456
Change subject: Allow tags in summary ...................................................................... Allow tags in summary This patch address T109032 by adding support for assigning tags to an edit from the summary using tags, that is #TAG_NAME will result in assigning tag to edit. This partially address T123529, but only for exlpicitly predefined tags (explicitly defined tags). Bug: T109032, T123529 Change-Id: If2dfc8e525d2710d122f40903d76e92c84beb1ab --- M includes/EditPage.php M includes/changetags/ChangeTags.php 2 files changed, 28 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/56/282456/1 diff --git a/includes/EditPage.php b/includes/EditPage.php index 3522531..10868ce 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -923,7 +923,11 @@ $changeTags = $request->getVal( 'wpChangeTags' ); if ( is_null( $changeTags ) || $changeTags === '' ) { - $this->changeTags = []; + // if tags aren't explicitly defined try to extract them from the summary + preg_match_all('/(?:^\#| \#)([^ ]+)/', $this->summary, $implicitTagMatches); + // TODO: ideally we should accept translated tags, that is wfMesssage(tag-$tag) => tag not only tag. + $existingTags = ChangeTags::allowedTagsAccompanyingChange( $implicitTagMatches[1] ); + $this->changeTags = $existingTags; } else { $this->changeTags = array_filter( array_map( 'trim', explode( ',', $changeTags ) ) ); diff --git a/includes/changetags/ChangeTags.php b/includes/changetags/ChangeTags.php index 9db1697..d4cff7d 100644 --- a/includes/changetags/ChangeTags.php +++ b/includes/changetags/ChangeTags.php @@ -398,6 +398,29 @@ return Status::newGood(); } + + /** + * List of tags user is allowed to add + * + * @param array $tags Tags that you are interested in applying + * @param User|null $user User whose permission you wish to check, or null if + * you don't care (e.g. maintenance scripts) + * @return Status + * @since 1.27 + */ + public static function allowedTagsAccompanyingChange( array $tags, + User $user = null ) { + + if ( !is_null( $user ) ) { + if ( !$user->isAllowed( 'applychangetags' ) || $user->isBlocked() ) { + return []; + } + } + + $allowedTags = self::listExplicitlyDefinedTags(); + return array_intersect( $tags, $allowedTags ); + } + /** * Adds tags to a given change, checking whether it is allowed first, but * without adding a log entry. Useful for cases where the tag is being added -- To view, visit https://gerrit.wikimedia.org/r/282456 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If2dfc8e525d2710d122f40903d76e92c84beb1ab Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Eranroz <eranro...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits