jenkins-bot has submitted this change and it was merged.
Change subject: ChangeTags: Don't show UI when no editable tags exist
......................................................................
ChangeTags: Don't show UI when no editable tags exist
Bug: T97773
Change-Id: I001f15ca6f58bc9318eed84aa8ace2bddcb1b315
---
M includes/ChangeTags.php
M includes/actions/HistoryAction.php
M includes/logging/LogEventsList.php
M includes/specials/SpecialLog.php
4 files changed, 26 insertions(+), 8 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/ChangeTags.php b/includes/ChangeTags.php
index 71771ba..09665df 100644
--- a/includes/ChangeTags.php
+++ b/includes/ChangeTags.php
@@ -1193,4 +1193,22 @@
$wgMemc->set( $key, $out, 300 );
return $out;
}
+
+ /**
+ * Indicate whether change tag editing UI is relevant
+ *
+ * Returns true if the user has the necessary right and there are any
+ * editable tags defined.
+ *
+ * This intentionally doesn't check "any addable || any deletable",
because
+ * it seems like it would be more confusing than useful if the
checkboxes
+ * suddenly showed up because some abuse filter stopped defining a tag
and
+ * then suddenly disappeared when someone deleted all uses of that tag.
+ *
+ * @param User $user
+ * @return bool
+ */
+ public static function showTagEditingUI( User $user ) {
+ return $user->isAllowed( 'changetags' ) &&
(bool)self::listExplicitlyDefinedTags();
+ }
}
diff --git a/includes/actions/HistoryAction.php
b/includes/actions/HistoryAction.php
index f38bc50..dcd7741 100644
--- a/includes/actions/HistoryAction.php
+++ b/includes/actions/HistoryAction.php
@@ -495,7 +495,7 @@
if ( $user->isAllowed( 'deleterevision' ) ) {
$actionButtons .= $this->getRevisionButton(
'revisiondelete', 'showhideselectedversions' );
}
- if ( $user->isAllowed( 'changetags' ) ) {
+ if ( ChangeTags::showTagEditingUI( $user ) ) {
$actionButtons .= $this->getRevisionButton(
'editchangetags', 'history-edit-tags' );
}
if ( $actionButtons ) {
@@ -617,14 +617,14 @@
$del = '';
$user = $this->getUser();
$canRevDelete = $user->isAllowed( 'deleterevision' );
- $canModifyTags = $user->isAllowed( 'changetags' );
+ $showTagEditUI = ChangeTags::showTagEditingUI( $user );
// Show checkboxes for each revision, to allow for revision
deletion and
// change tags
- if ( $canRevDelete || $canModifyTags ) {
+ if ( $canRevDelete || $showTagEditUI ) {
$this->preventClickjacking();
// If revision was hidden from sysops and we don't need
the checkbox
// for anything else, disable it
- if ( !$canModifyTags && !$rev->userCan(
Revision::DELETED_RESTRICTED, $user ) ) {
+ if ( !$showTagEditUI && !$rev->userCan(
Revision::DELETED_RESTRICTED, $user ) ) {
$del = Xml::check( 'deleterevisions', false,
array( 'disabled' => 'disabled' ) );
// Otherwise, enable the checkbox...
} else {
diff --git a/includes/logging/LogEventsList.php
b/includes/logging/LogEventsList.php
index dcddbd7..dfe3136 100644
--- a/includes/logging/LogEventsList.php
+++ b/includes/logging/LogEventsList.php
@@ -348,7 +348,7 @@
$user = $this->getUser();
// If change tag editing is available to this user, return the
checkbox
- if ( $this->flags & self::USE_CHECKBOXES && $user->isAllowed(
'changetags' ) ) {
+ if ( $this->flags & self::USE_CHECKBOXES &&
ChangeTags::showTagEditingUI( $user ) ) {
return Xml::check(
'showhiderevisions',
false,
diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php
index fe6ce68..e44ce5f 100644
--- a/includes/specials/SpecialLog.php
+++ b/includes/specials/SpecialLog.php
@@ -218,10 +218,10 @@
private function getActionButtons( $formcontents ) {
$user = $this->getUser();
$canRevDelete = $user->isAllowedAll( 'deletedhistory',
'deletelogentry' );
- $canModifyTags = $user->isAllowed( 'changetags' );
+ $showTagEditUI = ChangeTags::showTagEditingUI( $user );
# If the user doesn't have the ability to delete log entries
nor edit tags,
# don't bother showing them the button(s).
- if ( !$canRevDelete && !$canModifyTags ) {
+ if ( !$canRevDelete && !$showTagEditUI ) {
return $formcontents;
}
@@ -246,7 +246,7 @@
$this->msg( 'showhideselectedlogentries'
)->text()
) . "\n";
}
- if ( $canModifyTags ) {
+ if ( $showTagEditUI ) {
$buttons .= Html::element(
'button',
array(
--
To view, visit https://gerrit.wikimedia.org/r/208110
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I001f15ca6f58bc9318eed84aa8ace2bddcb1b315
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_25
Gerrit-Owner: Anomie <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: TTO <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits