jenkins-bot has submitted this change and it was merged.
Change subject: ChangeTags: Hide tags whose description messages are disabled
......................................................................
ChangeTags: Hide tags whose description messages are disabled
If an interface message describing the given tag exists, check if it has been
disabled. If so, take that as an indication that the tag should not be
displayed.
This amounts to an adequate (if somewhat low-level) interface for managing
which edit tags are shown in change list views like Special:RecentChanges and
Special:Contributions.
This patch is based on a suggestion made by jackmcbarn in a review comment on
commit 494989772cf. I did it in a separate change because I'd be interested in
hiding the HHVM tag even if we end up deciding against a generic mechanism for
hiding tags.
Change-Id: I515cf2118ab929da985d6b40481325640e800dcd
---
M RELEASE-NOTES-1.26
M includes/ChangeTags.php
2 files changed, 38 insertions(+), 7 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/RELEASE-NOTES-1.26 b/RELEASE-NOTES-1.26
index 46509be..89dad11 100644
--- a/RELEASE-NOTES-1.26
+++ b/RELEASE-NOTES-1.26
@@ -11,12 +11,16 @@
=== Configuration changes in 1.26 ===
=== New features in 1.26 ===
+* Change tags can now be hidden in the interface by disabling the associated
+ "tag-<id>" interface message.
==== External libraries ====
=== Bug fixes in 1.26 ===
=== Action API changes in 1.26 ===
+* API action=query&list=tags: The displayname can now be boolean false if the
+ tag is meant to be hidden from user interfaces.
=== Action API internal changes in 1.26 ===
@@ -28,7 +32,8 @@
=== Other changes in 1.26 ===
-
+* ChangeTags::tagDescription() will return false if the interface message
+ for the tag is disabled.
== Compatibility ==
diff --git a/includes/ChangeTags.php b/includes/ChangeTags.php
index 3103edd..e2ef75e 100644
--- a/includes/ChangeTags.php
+++ b/includes/ChangeTags.php
@@ -51,14 +51,26 @@
$tags = explode( ',', $tags );
$displayTags = array();
foreach ( $tags as $tag ) {
+ if ( !$tag ) {
+ continue;
+ }
+ $description = self::tagDescription( $tag );
+ if ( $description === false ) {
+ continue;
+ }
$displayTags[] = Xml::tags(
'span',
array( 'class' => 'mw-tag-marker ' .
Sanitizer::escapeClass( "mw-tag-marker-$tag" ) ),
- self::tagDescription( $tag )
+ $description
);
$classes[] = Sanitizer::escapeClass( "mw-tag-$tag" );
}
+
+ if ( !$displayTags ) {
+ return array( '', array() );
+ }
+
$markers = wfMessage( 'tag-list-wrapper' )
->numParams( count( $displayTags ) )
->rawParams( $wgLang->commaList( $displayTags ) )
@@ -69,16 +81,30 @@
}
/**
- * Get a short description for a tag
+ * Get a short description for a tag.
+ *
+ * Checks if message key "mediawiki:tag-$tag" exists. If it does not,
+ * returns the HTML-escaped tag name. Uses the message if the message
+ * exists, provided it is not disabled. If the message is disabled,
+ * we consider the tag hidden, and return false.
*
* @param string $tag Tag
- *
- * @return string Short description of the tag from
"mediawiki:tag-$tag" if this message exists,
- * html-escaped version of $tag otherwise
+ * @return string|bool Tag description or false if tag is to be hidden.
+ * @since 1.25 Returns false if tag is to be hidden.
*/
public static function tagDescription( $tag ) {
$msg = wfMessage( "tag-$tag" );
- return $msg->exists() ? $msg->parse() : htmlspecialchars( $tag
);
+ if ( !$msg->exists() ) {
+ // No such message, so return the HTML-escaped tag name.
+ return htmlspecialchars( $tag );
+ }
+ if ( $msg->isDisabled() ) {
+ // The message exists but is disabled, hide the tag.
+ return false;
+ }
+
+ // Message exists and isn't disabled, use it.
+ return $msg->parse();
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/172098
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I515cf2118ab929da985d6b40481325640e800dcd
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Jackmcbarn <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits