}
$taglessDesc = Sanitizer::stripAllTags( $originalDesc->parse() );
- $escapedDesc = Sanitizer::escapeHtmlAllowEntities( $taglessDesc );
- return $context->getLanguage()->truncateForVisual( $escapedDesc, $length );
+ return $context->getLanguage()->truncateForVisual( $taglessDesc, $length );
}
/**
if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD ) {
$dbw->update(
'change_tag_def',
- [ 'ctd_name' => $tag ],
[ 'ctd_user_defined' => 0 ],
+ [ 'ctd_name' => $tag ],
__METHOD__
);
* Extensions should NOT use this function; they can use the ListDefinedTags
* hook instead.
*
- * Includes a call to ChangeTag::canDeleteTag(), so your code doesn't need to
+ * Includes a call to ChangeTag::canCreateTag(), so your code doesn't need to
* do that.
*
* @param string $tag
* @return array Array of string => int
*/
public static function tagUsageStatistics() {
+ global $wgChangeTagsSchemaMigrationStage, $wgTagStatisticsNewTable;
+ if ( $wgChangeTagsSchemaMigrationStage > MIGRATION_WRITE_BOTH ||
+ ( $wgTagStatisticsNewTable && $wgChangeTagsSchemaMigrationStage > MIGRATION_OLD )
+ ) {
+ return self::newTagUsageStatistics();
+ }
+
$fname = __METHOD__;
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
return $cache->getWithSetCallback(
);
}
+ /**
+ * Same self::tagUsageStatistics() but uses change_tag_def.
+ *
+ * @return array Array of string => int
+ */
+ private static function newTagUsageStatistics() {
+ $dbr = wfGetDB( DB_REPLICA );
+ $res = $dbr->select(
+ 'change_tag_def',
+ [ 'ctd_name', 'ctd_count' ],
+ [],
+ __METHOD__,
+ [ 'ORDER BY' => 'ctd_count DESC' ]
+ );
+
+ $out = [];
+ foreach ( $res as $row ) {
+ $out[$row->ctd_name] = $row->ctd_count;
+ }
+
+ return $out;
+ }
+
/**
* Indicate whether change tag editing UI is relevant
*