'mw-changed-redirect-target',
'mw-blank',
'mw-replace',
- 'mw-rollback'
+ 'mw-rollback',
+ 'mw-undo',
];
/**
* exists, provided it is not disabled. If the message is disabled,
* we consider the tag hidden, and return false.
*
- * @param string $tag Tag
+ * @param string $tag
* @param IContextSource $context
* @return string|bool Tag description or false if tag is to be hidden.
* @since 1.25 Returns false if tag is to be hidden.
* or if message is disabled, returns false. Otherwise, returns the message object
* for the long description.
*
- * @param string $tag Tag
+ * @param string $tag
* @param IContextSource $context
* @return Message|bool Message object of the tag long description or false if
* there is no description.
return $msg;
}
+ /**
+ * Get truncated message for the tag's long description.
+ *
+ * @param string $tag Tag name.
+ * @param int $length Maximum length of truncated message, including ellipsis.
+ * @param IContextSource $context
+ *
+ * @return string Truncated long tag description.
+ */
+ public static function truncateTagDescription( $tag, $length, IContextSource $context ) {
+ $originalDesc = self::tagLongDescriptionMessage( $tag, $context );
+ // If there is no tag description, return empty string
+ if ( !$originalDesc ) {
+ return '';
+ }
+
+ $taglessDesc = Sanitizer::stripAllTags( $originalDesc->parse() );
+ $escapedDesc = Sanitizer::escapeHtmlAllowEntities( $taglessDesc );
+
+ return $context->getLanguage()->truncateForVisual( $escapedDesc, $length );
+ }
+
/**
* Add tags to a change given its rc_id, rev_id and/or log_id
*
sort( $prevTags );
sort( $newTags );
if ( $prevTags == $newTags ) {
- // No change.
return false;
}
if ( !$newTags ) {
- // no tags left, so delete the row altogether
+ // No tags left, so delete the row altogether
$dbw->delete( 'tag_summary', $tsConds, __METHOD__ );
} else {
- $dbw->replace( 'tag_summary',
- [ 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ],
- array_filter( array_merge( $tsConds, [ 'ts_tags' => implode( ',', $newTags ) ] ) ),
- __METHOD__
- );
+ // Specify the non-DEFAULT value columns in the INSERT/REPLACE clause
+ $row = array_filter( [ 'ts_tags' => implode( ',', $newTags ) ] + $tsConds );
+ // Check the unique keys for conflicts, ignoring any NULL *_id values
+ $uniqueKeys = [];
+ foreach ( [ 'ts_rev_id', 'ts_rc_id', 'ts_log_id' ] as $uniqueColumn ) {
+ if ( isset( $row[$uniqueColumn] ) ) {
+ $uniqueKeys[] = [ $uniqueColumn ];
+ }
+ }
+
+ $dbw->replace( 'tag_summary', $uniqueKeys, $row, __METHOD__ );
}
return true;