return Status::newFatal( 'tags-manage-no-permission' );
}
- // non-existing tags cannot be activated
- $tagUsage = self::tagUsageStatistics();
- if ( !isset( $tagUsage[$tag] ) ) {
- return Status::newFatal( 'tags-activate-not-found', $tag );
- }
-
// defined tags cannot be activated (a defined tag is either extension-
// defined, in which case the extension chooses whether or not to active it;
// or user-defined, in which case it is considered active)
return Status::newFatal( 'tags-activate-not-allowed', $tag );
}
+ // non-existing tags cannot be activated
+ $tagUsage = self::tagUsageStatistics();
+ if ( !isset( $tagUsage[$tag] ) ) { // we already know the tag is undefined
+ return Status::newFatal( 'tags-activate-not-found', $tag );
+ }
+
return Status::newGood();
}
// does the tag already exist?
$tagUsage = self::tagUsageStatistics();
- if ( isset( $tagUsage[$tag] ) ) {
+ if ( isset( $tagUsage[$tag] ) || in_array( $tag, self::listDefinedTags() ) ) {
return Status::newFatal( 'tags-create-already-exists', $tag );
}
return Status::newFatal( 'tags-manage-no-permission' );
}
- if ( !isset( $tagUsage[$tag] ) ) {
+ if ( !isset( $tagUsage[$tag] ) && !in_array( $tag, self::listDefinedTags() ) ) {
return Status::newFatal( 'tags-delete-not-found', $tag );
}
- if ( $tagUsage[$tag] > self::MAX_DELETE_USES ) {
+ if ( isset( $tagUsage[$tag] ) && $tagUsage[$tag] > self::MAX_DELETE_USES ) {
return Status::newFatal( 'tags-delete-too-many-uses', $tag, self::MAX_DELETE_USES );
}
// store the tag usage statistics
$tagUsage = self::tagUsageStatistics();
+ $hitcount = isset( $tagUsage[$tag] ) ? $tagUsage[$tag] : 0;
// do it!
$deleteResult = self::deleteTagEverywhere( $tag );
}
// log it
- $logId = self::logTagManagementAction( 'delete', $tag, $reason, $user, $tagUsage[$tag] );
+ $logId = self::logTagManagementAction( 'delete', $tag, $reason, $user, $hitcount );
$deleteResult->value = $logId;
return $deleteResult;
}