MediaWiki master
ChangeTags Class Reference

Static Public Member Functions

static activateTagWithChecks (string $tag, string $reason, Authority $performer, bool $ignoreWarnings=false, array $logEntryTags=[])
 Activates a tag, checking whether it is allowed first, and adding a log entry afterwards.
 
static addTags ( $tags, $rc_id=null, $rev_id=null, $log_id=null, $params=null, RecentChange $rc=null)
 Add tags to a change given its rc_id, rev_id and/or log_id.
 
static buildTagFilterSelector ( $selected='', $ooui=false, IContextSource $context=null)
 Build a text box to select a change tag.
 
static canActivateTag ( $tag, Authority $performer=null)
 Is it OK to allow the user to activate this tag?
 
static canAddTagsAccompanyingChange (array $tags, Authority $performer=null, $checkBlock=true)
 Is it OK to allow the user to apply all the specified tags at the same time as they edit/make the change?
 
static canCreateTag ( $tag, Authority $performer=null)
 Is it OK to allow the user to create this tag?
 
static canDeactivateTag ( $tag, Authority $performer=null)
 Is it OK to allow the user to deactivate this tag?
 
static canDeleteTag ( $tag, Authority $performer=null, int $flags=0)
 Is it OK to allow the user to delete this tag?
 
static canUpdateTags (array $tagsToAdd, array $tagsToRemove, Authority $performer=null)
 Is it OK to allow the user to adds and remove the given tags to/from a change?
 
static createTagWithChecks (string $tag, string $reason, Authority $performer, bool $ignoreWarnings=false, array $logEntryTags=[])
 Creates a tag by adding it to change_tag_def table.
 
static deactivateTagWithChecks (string $tag, string $reason, Authority $performer, bool $ignoreWarnings=false, array $logEntryTags=[])
 Deactivates a tag, checking whether it is allowed first, and adding a log entry afterwards.
 
static defineTag ( $tag)
 Set ctd_user_defined = 1 in change_tag_def without checking that the tag name is valid.
 
static deleteTagEverywhere ( $tag)
 Permanently removes all traces of a tag from the DB.
 
static deleteTagWithChecks (string $tag, string $reason, Authority $performer, bool $ignoreWarnings=false, array $logEntryTags=[])
 Deletes a tag, checking whether it is allowed first, and adding a log entry afterwards.
 
static formatSummaryRow ( $tags, $unused, MessageLocalizer $localizer=null)
 Creates HTML for the given tags.
 
static getChangeTagList (MessageLocalizer $localizer, Language $lang)
 Get information about change tags for tag filter dropdown menus.
 
static getChangeTagListSummary (MessageLocalizer $localizer, Language $lang)
 Get information about change tags, without parsing messages, for tag filter dropdown menus.
 
static getDisplayTableName ()
 Get the name of the change_tag table to use for modifyDisplayQuery().
 
static getSoftwareTags ( $all=false)
 Loads defined core tags, checks for invalid types (if not array), and filters for supported and enabled (if $all is false) tags only.
 
static getTags (IReadableDatabase $db, $rc_id=null, $rev_id=null, $log_id=null)
 Return all the tags associated with the given recent change ID, revision ID, and/or log entry ID.
 
static getTagsWithData (IReadableDatabase $db, $rc_id=null, $rev_id=null, $log_id=null)
 Return all the tags associated with the given recent change ID, revision ID, and/or log entry ID, along with any data stored with the tag.
 
static isTagNameValid ( $tag)
 Is the tag name valid?
 
static listDefinedTags ()
 Basically lists defined tags which count even if they aren't applied to anything.
 
static listExplicitlyDefinedTags ()
 Lists tags explicitly defined in the change_tag_def table of the database.
 
static listSoftwareActivatedTags ()
 Lists those tags which core or extensions report as being "active".
 
static listSoftwareDefinedTags ()
 Lists tags defined by core or extensions using the ListDefinedTags hook.
 
static makeTagSummarySubquery ( $tables)
 Make the tag summary subquery based on the given tables and return it.
 
static modifyDisplayQuery (&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='', bool $exclude=false)
 Applies all tags-related changes to a query.
 
static purgeTagCacheAll ()
 Invalidates the short-term cache of defined tags used by the list*DefinedTags functions, as well as the tag statistics cache.
 
static showTagEditingUI (Authority $performer)
 Indicate whether change tag editing UI is relevant.
 
static tagDescription ( $tag, MessageLocalizer $context)
 Get a short description for a tag.
 
static tagLongDescriptionMessage ( $tag, MessageLocalizer $context)
 Get the message object for the tag's long description.
 
static tagShortDescriptionMessage ( $tag, MessageLocalizer $context)
 Get the message object for the tag's short description.
 
static tagUsageStatistics ()
 Returns a map of any tags used on the wiki to number of edits tagged with them, ordered descending by the hitcount.
 
static updateTags ( $tagsToAdd, $tagsToRemove, &$rc_id=null, &$rev_id=null, &$log_id=null, $params=null, RecentChange $rc=null, UserIdentity $user=null)
 Add and remove tags to/from a change given its rc_id, rev_id and/or log_id, without verifying that the tags exist or are valid.
 
static updateTagsWithChecks ( $tagsToAdd, $tagsToRemove, $rc_id, $rev_id, $log_id, $params, string $reason, Authority $performer)
 Adds and/or removes tags to/from a given change, checking whether it is allowed first, and adding a log entry afterwards.
 

Public Attributes

const BYPASS_MAX_USAGE_CHECK = 1
 Flag for canDeleteTag().
 
const DISPLAY_TABLE_ALIAS = 'changetagdisplay'
 
const REVERT_TAGS = [ self::TAG_ROLLBACK, self::TAG_UNDO, self::TAG_MANUAL_REVERT ]
 List of tags which denote a revert of some sort.
 
const TAG_BLANK = 'mw-blank'
 The tagged edit blanks the page (replaces it with the empty string).
 
const TAG_CHANGED_REDIRECT_TARGET = 'mw-changed-redirect-target'
 The tagged edit changes the target of a redirect page.
 
const TAG_CONTENT_MODEL_CHANGE = 'mw-contentmodelchange'
 The tagged edit changes the content model of the page.
 
const TAG_MANUAL_REVERT = 'mw-manual-revert'
 The tagged edit restores the page to an earlier revision.
 
const TAG_NEW_REDIRECT = 'mw-new-redirect'
 The tagged edit creates a new redirect (either by creating a new page or turning an existing page into a redirect).
 
const TAG_REMOVED_REDIRECT = 'mw-removed-redirect'
 The tagged edit turns a redirect page into a non-redirect.
 
const TAG_REPLACE = 'mw-replace'
 The tagged edit removes more than 90% of the content of the page.
 
const TAG_REVERTED = 'mw-reverted'
 The tagged edit is reverted by a subsequent edit (which is tagged by one of TAG_ROLLBACK, TAG_UNDO, TAG_MANUAL_REVERT).
 
const TAG_ROLLBACK = 'mw-rollback'
 The tagged edit is a rollback (undoes the previous edit and all immediately preceding edits by the same user, and was performed via the "rollback" link available to advanced users or via the rollback API).
 
const TAG_SERVER_SIDE_UPLOAD = 'mw-server-side-upload'
 This tagged edit was performed while importing media files using the importImages.php maintenance script.
 
const TAG_UNDO = 'mw-undo'
 The tagged edit is was performed via the "undo" link.
 

Static Protected Member Functions

static restrictedTagError ( $msgOne, $msgMulti, $tags)
 Helper function to generate a fatal status with a 'not-allowed' type error.
 

Detailed Description

Definition at line 40 of file ChangeTags.php.

Member Function Documentation

◆ activateTagWithChecks()

static ChangeTags::activateTagWithChecks ( string  $tag,
string  $reason,
Authority  $performer,
bool  $ignoreWarnings = false,
array  $logEntryTags = [] 
)
static

Activates a tag, checking whether it is allowed first, and adding a log entry afterwards.

Includes a call to ChangeTag::canActivateTag(), so your code doesn't need to do that.

Parameters
string$tag
string$reason
Authority$performerwho to check permissions and give credit for the action
bool$ignoreWarningsCan be used for API interaction, default false
array$logEntryTagsChange tags to apply to the entry that will be created in the tag management log
Returns
Status If successful, the Status contains the ID of the added log entry as its value
Since
1.25

Definition at line 811 of file ChangeTags.php.

References canActivateTag(), and MediaWiki\Permissions\Authority\getUser().

Referenced by ApiManageTags\execute().

◆ addTags()

static ChangeTags::addTags (   $tags,
  $rc_id = null,
  $rev_id = null,
  $log_id = null,
  $params = null,
RecentChange  $rc = null 
)
static

Add tags to a change given its rc_id, rev_id and/or log_id.

Deprecated:
since 1.41 use ChangeTagsStore instead.
Parameters
string | string[]$tagsTags to add to the change
int | null$rc_idThe rc_id of the change to add the tags to
int | null$rev_idThe rev_id of the change to add the tags to
int | null$log_idThe log_id of the change to add the tags to
string | null$paramsParams to put in the ct_params field of table 'change_tag'
RecentChange | null$rcRecent change, in case the tagging accompanies the action (this should normally be the case)
Returns
bool False if no changes are made, otherwise true

Definition at line 284 of file ChangeTags.php.

References $params.

Referenced by ImportableOldRevisionImporter\import(), and RecentChange\save().

◆ buildTagFilterSelector()

static ChangeTags::buildTagFilterSelector (   $selected = '',
  $ooui = false,
IContextSource  $context = null 
)
static

Build a text box to select a change tag.

Parameters
string$selectedTag to select by default
bool$oouiUse an OOUI TextInputWidget as selector instead of a non-OOUI input field You need to call OutputPage::enableOOUI() yourself.
IContextSource | null$context
Note
Even though it takes null as a valid argument, an IContextSource is preferred in a new code, as the null value can change in the future
Returns
array an array of (label, selector)

Definition at line 683 of file ChangeTags.php.

References getChangeTagList().

Referenced by MediaWiki\HTMLForm\Field\HTMLTagFilter\getDiv(), MediaWiki\Specials\SpecialRecentChanges\getExtraOptions(), MediaWiki\HTMLForm\Field\HTMLTagFilter\getOOUI(), and MediaWiki\HTMLForm\Field\HTMLTagFilter\getTableRow().

◆ canActivateTag()

static ChangeTags::canActivateTag (   $tag,
Authority  $performer = null 
)
static

Is it OK to allow the user to activate this tag?

Parameters
string$tagTag that you are interested in activating
Authority | null$performerwhose permission you wish to check, or null if you don't care (e.g. maintenance scripts)
Returns
Status
Since
1.25

Definition at line 764 of file ChangeTags.php.

Referenced by activateTagWithChecks(), and MediaWiki\Specials\SpecialTags\showActivateDeactivateForm().

◆ canAddTagsAccompanyingChange()

static ChangeTags::canAddTagsAccompanyingChange ( array  $tags,
Authority  $performer = null,
  $checkBlock = true 
)
static

Is it OK to allow the user to apply all the specified tags at the same time as they edit/make the change?

Extensions should not use this function, unless directly handling a user request to add a tag to a revision or log entry that the user is making.

Parameters
string[]$tagsTags that you are interested in applying
Authority | null$performerwhose permission you wish to check, or null to check for a generic non-blocked user with the relevant rights
bool$checkBlockWhether to check the blocked status of $performer
Returns
Status
Since
1.25

Definition at line 398 of file ChangeTags.php.

References restrictedTagError().

Referenced by ApiEditPage\execute(), ApiImageRotate\execute(), ApiImport\execute(), ApiManageTags\execute(), ApiPatrol\execute(), ApiProtect\execute(), ApiRevisionDelete\execute(), ApiRollback\execute(), ApiSetPageLanguage\execute(), ApiTag\execute(), ApiUserrights\execute(), MediaWiki\Page\MovePage\moveIfAllowed(), ApiUpload\performUpload(), MediaWiki\Specials\SpecialUpload\processUpload(), ContentModelChange\setTags(), and MediaWiki\ParamValidator\TypeDef\TagsDef\validate().

◆ canCreateTag()

static ChangeTags::canCreateTag (   $tag,
Authority  $performer = null 
)
static

Is it OK to allow the user to create this tag?

Extensions should NOT use this function. In most cases, a tag can be defined using the ListDefinedTags hook without any checking.

Parameters
string$tagTag that you are interested in creating
Authority | null$performerwhose permission you wish to check, or null if you don't care (e.g. maintenance scripts)
Returns
Status
Since
1.25

Definition at line 939 of file ChangeTags.php.

References isTagNameValid().

Referenced by createTagWithChecks().

◆ canDeactivateTag()

static ChangeTags::canDeactivateTag (   $tag,
Authority  $performer = null 
)
static

Is it OK to allow the user to deactivate this tag?

Parameters
string$tagTag that you are interested in deactivating
Authority | null$performerwhose permission you wish to check, or null if you don't care (e.g. maintenance scripts)
Returns
Status
Since
1.25

Definition at line 839 of file ChangeTags.php.

Referenced by deactivateTagWithChecks(), and MediaWiki\Specials\SpecialTags\showActivateDeactivateForm().

◆ canDeleteTag()

static ChangeTags::canDeleteTag (   $tag,
Authority  $performer = null,
int  $flags = 0 
)
static

Is it OK to allow the user to delete this tag?

Parameters
string$tagTag that you are interested in deleting
Authority | null$performerwhose permission you wish to check, or null if you don't care (e.g. maintenance scripts)
int$flagsUse ChangeTags::BYPASS_MAX_USAGE_CHECK to ignore whether there are more uses than we would normally allow to be deleted through the user interface.
Returns
Status
Since
1.25

Definition at line 1042 of file ChangeTags.php.

Referenced by deleteTagWithChecks(), DeleteTag\execute(), and MediaWiki\Specials\SpecialTags\showDeleteTagForm().

◆ canUpdateTags()

static ChangeTags::canUpdateTags ( array  $tagsToAdd,
array  $tagsToRemove,
Authority  $performer = null 
)
static

Is it OK to allow the user to adds and remove the given tags to/from a change?

Extensions should not use this function, unless directly handling a user request to add or remove tags from an existing revision or log entry.

Parameters
string[]$tagsToAddTags that you are interested in adding
string[]$tagsToRemoveTags that you are interested in removing
Authority | null$performerwhose permission you wish to check, or null to check for a generic non-blocked user with the relevant rights
Returns
Status
Since
1.25

Definition at line 447 of file ChangeTags.php.

References restrictedTagError().

Referenced by updateTagsWithChecks().

◆ createTagWithChecks()

static ChangeTags::createTagWithChecks ( string  $tag,
string  $reason,
Authority  $performer,
bool  $ignoreWarnings = false,
array  $logEntryTags = [] 
)
static

Creates a tag by adding it to change_tag_def table.

Extensions should NOT use this function; they can use the ListDefinedTags hook instead.

Includes a call to ChangeTag::canCreateTag(), so your code doesn't need to do that.

Parameters
string$tag
string$reason
Authority$performerwho to check permissions and give credit for the action
bool$ignoreWarningsCan be used for API interaction, default false
array$logEntryTagsChange tags to apply to the entry that will be created in the tag management log
Returns
Status If successful, the Status contains the ID of the added log entry as its value
Since
1.25

Definition at line 995 of file ChangeTags.php.

References canCreateTag(), and MediaWiki\Permissions\Authority\getUser().

Referenced by ApiManageTags\execute(), AddChangeTag\execute(), and MediaWiki\Specials\SpecialTags\processCreateTagForm().

◆ deactivateTagWithChecks()

static ChangeTags::deactivateTagWithChecks ( string  $tag,
string  $reason,
Authority  $performer,
bool  $ignoreWarnings = false,
array  $logEntryTags = [] 
)
static

Deactivates a tag, checking whether it is allowed first, and adding a log entry afterwards.

Includes a call to ChangeTag::canDeactivateTag(), so your code doesn't need to do that.

Parameters
string$tag
string$reason
Authority$performerwho to check permissions and give credit for the action
bool$ignoreWarningsCan be used for API interaction, default false
array$logEntryTagsChange tags to apply to the entry that will be created in the tag management log
Returns
Status If successful, the Status contains the ID of the added log entry as its value
Since
1.25

Definition at line 877 of file ChangeTags.php.

References canDeactivateTag(), and MediaWiki\Permissions\Authority\getUser().

Referenced by ApiManageTags\execute().

◆ defineTag()

static ChangeTags::defineTag (   $tag)
static

Set ctd_user_defined = 1 in change_tag_def without checking that the tag name is valid.

Extensions should NOT use this function; they can use the ListDefinedTags hook instead.

Deprecated:
since 1.41 use ChangeTagsStore
Parameters
string$tagTag to create
Since
1.25

Definition at line 751 of file ChangeTags.php.

◆ deleteTagEverywhere()

static ChangeTags::deleteTagEverywhere (   $tag)
static

Permanently removes all traces of a tag from the DB.

Good for removing misspelt or temporary tags.

This function should be directly called by maintenance scripts only, never by user-facing code. See deleteTagWithChecks() for functionality that can safely be exposed to users.

Deprecated:
since 1.41 use ChangeTagsStore instead
Parameters
string$tagTag to remove
Returns
Status The returned status will be good unless a hook changed it
Since
1.25

Definition at line 1026 of file ChangeTags.php.

Referenced by DeleteTag\execute().

◆ deleteTagWithChecks()

static ChangeTags::deleteTagWithChecks ( string  $tag,
string  $reason,
Authority  $performer,
bool  $ignoreWarnings = false,
array  $logEntryTags = [] 
)
static

Deletes a tag, checking whether it is allowed first, and adding a log entry afterwards.

Includes a call to ChangeTag::canDeleteTag(), so your code doesn't need to do that.

Parameters
string$tag
string$reason
Authority$performerwho to check permissions and give credit for the action
bool$ignoreWarningsCan be used for API interaction, default false
array$logEntryTagsChange tags to apply to the entry that will be created in the tag management log
Returns
Status If successful, the Status contains the ID of the added log entry as its value
Since
1.25

Definition at line 1106 of file ChangeTags.php.

References canDeleteTag(), and MediaWiki\Permissions\Authority\getUser().

Referenced by ApiManageTags\execute().

◆ formatSummaryRow()

static ChangeTags::formatSummaryRow (   $tags,
  $unused,
MessageLocalizer  $localizer = null 
)
static

Creates HTML for the given tags.

Parameters
string$tagsComma-separated list of tags
null | string$unusedUnused (formerly: $page)
MessageLocalizer | null$localizer
Note
Even though it takes null as a valid argument, a MessageLocalizer is preferred in a new code, as the null value is subject to change in the future
Returns
array Array with two items: (html, classes)
  • html: String: HTML for displaying the tags (empty string when param $tags is empty)
  • classes: Array of strings: CSS classes used in the generated html, one class for each tag

Definition at line 149 of file ChangeTags.php.

References listDefinedTags(), and tagDescription().

Referenced by MediaWiki\Specials\SpecialUndelete\formatRevisionRow(), MediaWiki\Pager\HistoryPager\formatRow(), MediaWiki\Pager\ContribsPager\formatRow(), MediaWiki\Pager\MergeHistoryPager\formatRow(), MediaWiki\Pager\NewPagesPager\formatRow(), ChangeTagsLogItem\getHTML(), ChangeTagsRevisionItem\getHTML(), RevDelLogItem\getHTML(), RevDelRevisionItem\getHTML(), ChangesList\insertTags(), LogEventsList\logLine(), and DifferenceEngine\showDiffPage().

◆ getChangeTagList()

static ChangeTags::getChangeTagList ( MessageLocalizer  $localizer,
Language  $lang 
)
static

Get information about change tags for tag filter dropdown menus.

This manipulates the label and description of each tag, which are parsed, stripped and (in the case of description) truncated versions of these messages. Message parsing is expensive, so to detect whether the tag list has changed, use getChangeTagListSummary() instead.

Parameters
MessageLocalizer$localizer
Language$lang
Returns
array[] Same as getChangeTagListSummary(), with messages parsed, stripped and truncated

Definition at line 1284 of file ChangeTags.php.

References getChangeTagListSummary(), MessageLocalizer\msg(), and Language\truncateForVisual().

Referenced by buildTagFilterSelector(), and MediaWiki\SpecialPage\ChangesListSpecialPage\getRcFiltersConfigVars().

◆ getChangeTagListSummary()

static ChangeTags::getChangeTagListSummary ( MessageLocalizer  $localizer,
Language  $lang 
)
static

Get information about change tags, without parsing messages, for tag filter dropdown menus.

Message contents are the raw values (->plain()), because parsing messages is expensive. Even though we're not parsing messages, building a data structure with the contents of hundreds of i18n messages is still not cheap (see T223260#5370610), so this function caches its output in WANCache for up to 24 hours.

Returns an array of associative arrays with information about each tag:

  • name: Tag name (string)
  • labelMsg: Short description message (Message object, or false for hidden tags)
  • label: Short description message (raw message contents)
  • descriptionMsg: Long description message (Message object)
  • description: Long description message (raw message contents)
  • cssClass: CSS class to use for RC entries with this tag
  • hits: Number of RC entries that have this tag

This data is consumed by the mediawiki.rcfilters.filters.ui module, specifically mw.rcfilters.dm.FilterGroup and mw.rcfilters.dm.FilterItem.

Parameters
MessageLocalizer$localizer
Language$lang
Returns
array[] Information about each tag

Definition at line 1237 of file ChangeTags.php.

References Language\getCode(), tagLongDescriptionMessage(), and tagShortDescriptionMessage().

Referenced by getChangeTagList(), and MediaWiki\SpecialPage\ChangesListSpecialPage\getRcFiltersConfigSummary().

◆ getDisplayTableName()

static ChangeTags::getDisplayTableName ( )
static

Get the name of the change_tag table to use for modifyDisplayQuery().

This also does first-call initialisation of the table in testing mode.

Deprecated:
since 1.41 use ChangeTags::CHANGE_TAG or 'change_tag' instead. Note that directly querying this table is discouraged, try using one of the existing functions instead.
Returns
string

Definition at line 656 of file ChangeTags.php.

◆ getSoftwareTags()

static ChangeTags::getSoftwareTags (   $all = false)
static

Loads defined core tags, checks for invalid types (if not array), and filters for supported and enabled (if $all is false) tags only.

Parameters
bool$allIf true, return all valid defined tags. Otherwise, return only enabled ones.
Returns
array Array of all defined/enabled tags.
Deprecated:
since 1.41 use ChangeTagsStore::getSoftwareTags() instead.

Definition at line 132 of file ChangeTags.php.

Referenced by ImportImages\execute(), and ContentHandler\getChangeTag().

◆ getTags()

static ChangeTags::getTags ( IReadableDatabase  $db,
  $rc_id = null,
  $rev_id = null,
  $log_id = null 
)
static

Return all the tags associated with the given recent change ID, revision ID, and/or log entry ID.

Deprecated:
since 1.41 use ChangeTagStore::getTags()
Parameters
IReadableDatabase$dbthe database to query
int | null$rc_id
int | null$rev_id
int | null$log_id
Returns
string[]

Definition at line 360 of file ChangeTags.php.

◆ getTagsWithData()

static ChangeTags::getTagsWithData ( IReadableDatabase  $db,
  $rc_id = null,
  $rev_id = null,
  $log_id = null 
)
static

Return all the tags associated with the given recent change ID, revision ID, and/or log entry ID, along with any data stored with the tag.

Deprecated:
since 1.41 use ChangeTagStore::getTagsWithData()
Parameters
IReadableDatabase$dbthe database to query
int | null$rc_id
int | null$rev_id
int | null$log_id
Returns
string[] Tag name => data. Data format is tag-specific.
Since
1.36

Definition at line 343 of file ChangeTags.php.

◆ isTagNameValid()

static ChangeTags::isTagNameValid (   $tag)
static

Is the tag name valid?

Parameters
string$tagTag that you are interested in creating
Returns
Status
Since
1.30

Definition at line 903 of file ChangeTags.php.

References NS_MEDIAWIKI.

Referenced by canCreateTag().

◆ listDefinedTags()

static ChangeTags::listDefinedTags ( )
static

Basically lists defined tags which count even if they aren't applied to anything.

It returns a union of the results of listExplicitlyDefinedTags() and listSoftwareDefinedTags()

Deprecated:
since 1.41 use ChangeTagsStore instead
Returns
string[] Array of strings: tags

Definition at line 1154 of file ChangeTags.php.

Referenced by formatSummaryRow(), and ApiFeedContributions\getAllowedParams().

◆ listExplicitlyDefinedTags()

static ChangeTags::listExplicitlyDefinedTags ( )
static

Lists tags explicitly defined in the change_tag_def table of the database.

Tries memcached first.

Deprecated:
since 1.41 use ChangeTagsStore instead
Returns
string[] Array of strings: tags
Since
1.25

Definition at line 1167 of file ChangeTags.php.

◆ listSoftwareActivatedTags()

static ChangeTags::listSoftwareActivatedTags ( )
static

Lists those tags which core or extensions report as being "active".

Deprecated:
since 1.41 use ChangeTagsStore instead
Returns
array
Since
1.25

Definition at line 1142 of file ChangeTags.php.

◆ listSoftwareDefinedTags()

static ChangeTags::listSoftwareDefinedTags ( )
static

Lists tags defined by core or extensions using the ListDefinedTags hook.

Extensions need only define those tags they deem to be in active use.

Tries memcached first.

Deprecated:
since 1.41 use ChangeTagsStore instead
Returns
string[] Array of strings: tags
Since
1.25

Definition at line 1181 of file ChangeTags.php.

◆ makeTagSummarySubquery()

static ChangeTags::makeTagSummarySubquery (   $tables)
static

Make the tag summary subquery based on the given tables and return it.

Deprecated:
since 1.41 use ChangeTagStore instead
Parameters
string | array$tablesTable names, see Database::select
Returns
string tag summary subqeury

Definition at line 668 of file ChangeTags.php.

Referenced by ApiQueryDeletedrevs\execute(), ApiQueryLogEvents\execute(), ApiQueryRecentChanges\run(), ApiQueryAllDeletedRevisions\run(), ApiQueryAllRevisions\run(), ApiQueryDeletedRevisions\run(), and ApiQueryRevisions\run().

◆ modifyDisplayQuery()

static ChangeTags::modifyDisplayQuery ( $tables,
$fields,
$conds,
$join_conds,
$options,
  $filter_tag = '',
bool  $exclude = false 
)
static

Applies all tags-related changes to a query.

Handles selecting tags, and filtering. Needs $tables to be set up properly, so we can figure out which join conditions to use.

WARNING: If $filter_tag contains more than one tag and $exclude is false, this function will add DISTINCT, which may cause performance problems for your query unless you put the ID field of your table at the end of the ORDER BY, and set a GROUP BY equal to the ORDER BY. For example, if you had ORDER BY foo_timestamp DESC, you will now need GROUP BY foo_timestamp, foo_id ORDER BY foo_timestamp DESC, foo_id DESC.

Deprecated:
since 1.41 use ChangeTagsStore::modifyDisplayQueryBuilder instead
Parameters
string | array&$tablesTable names, see Database::select
string | array&$fieldsFields used in query, see Database::select
string | array&$condsConditions used in query, see Database::select
array&$join_condsJoin conditions, see Database::select
string | array&$optionsOptions, see Database::select
string | array | false | null$filter_tagTag(s) to select on (OR)
bool$excludeIf true, exclude tag(s) from $filter_tag (NOR)

Definition at line 633 of file ChangeTags.php.

Referenced by MediaWiki\SpecialPage\ChangesListSpecialPage\doMainQuery(), and MediaWiki\Pager\ContribsPager\getQueryInfo().

◆ purgeTagCacheAll()

static ChangeTags::purgeTagCacheAll ( )
static

Invalidates the short-term cache of defined tags used by the list*DefinedTags functions, as well as the tag statistics cache.

Deprecated:
since 1.41 use ChangeTagsStore instead
Since
1.25

Definition at line 1191 of file ChangeTags.php.

Referenced by DeleteTag\execute().

◆ restrictedTagError()

static ChangeTags::restrictedTagError (   $msgOne,
  $msgMulti,
  $tags 
)
staticprotected

Helper function to generate a fatal status with a 'not-allowed' type error.

Parameters
string$msgOneMessage key to use in the case of one tag
string$msgMultiMessage key to use in the case of more than one tag
string[]$tagsRestricted tags (passed as $1 into the message, count of $tags passed as $2)
Returns
Status
Since
1.25

Definition at line 374 of file ChangeTags.php.

Referenced by canAddTagsAccompanyingChange(), and canUpdateTags().

◆ showTagEditingUI()

static ChangeTags::showTagEditingUI ( Authority  $performer)
static

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.

Parameters
Authority$performer
Returns
bool

Definition at line 1326 of file ChangeTags.php.

References MediaWiki\Permissions\Authority\isAllowed().

Referenced by LogEventsList\__construct(), and MediaWiki\Pager\HistoryPager\__construct().

◆ tagDescription()

static ChangeTags::tagDescription (   $tag,
MessageLocalizer  $context 
)
static

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.

Parameters
string$tag
MessageLocalizer$context
Returns
string|false Tag description or false if tag is to be hidden.
Since
1.25 Returns false if tag is to be hidden.

Definition at line 239 of file ChangeTags.php.

References tagShortDescriptionMessage().

Referenced by ApiQueryTags\execute(), and formatSummaryRow().

◆ tagLongDescriptionMessage()

static ChangeTags::tagLongDescriptionMessage (   $tag,
MessageLocalizer  $context 
)
static

Get the message object for the tag's long description.

Checks if message key "mediawiki:tag-$tag-description" exists. If it does not, or if message is disabled, returns false. Otherwise, returns the message object for the long description.

Parameters
string$tag
MessageLocalizer$context
Returns
Message|false Message object of the tag long description or false if there is no description.

Definition at line 256 of file ChangeTags.php.

References MessageLocalizer\msg().

Referenced by getChangeTagListSummary().

◆ tagShortDescriptionMessage()

static ChangeTags::tagShortDescriptionMessage (   $tag,
MessageLocalizer  $context 
)
static

Get the message object for the tag's short description.

Checks if message key "mediawiki:tag-$tag" exists. If it does not, returns the tag name in a RawMessage. If the message exists, it is used, provided it is not disabled. If the message is disabled, we consider the tag hidden, and return false.

Since
1.34
Parameters
string$tag
MessageLocalizer$context
Returns
Message|false Tag description, or false if tag is to be hidden.

Definition at line 209 of file ChangeTags.php.

References MessageLocalizer\msg().

Referenced by getChangeTagListSummary(), and tagDescription().

◆ tagUsageStatistics()

static ChangeTags::tagUsageStatistics ( )
static

Returns a map of any tags used on the wiki to number of edits tagged with them, ordered descending by the hitcount.

This does not include tags defined somewhere that have never been applied.

Deprecated:
since 1.41 use ChangeTagsStore
Returns
array Array of string => int

Definition at line 1203 of file ChangeTags.php.

◆ updateTags()

static ChangeTags::updateTags (   $tagsToAdd,
  $tagsToRemove,
$rc_id = null,
$rev_id = null,
$log_id = null,
  $params = null,
RecentChange  $rc = null,
UserIdentity  $user = null 
)
static

Add and remove tags to/from a change given its rc_id, rev_id and/or log_id, without verifying that the tags exist or are valid.

If a tag is present in both $tagsToAdd and $tagsToRemove, it will be removed.

This function should only be used by extensions to manipulate tags they have registered using the ListDefinedTags hook. When dealing with user input, call updateTagsWithChecks() instead.

Deprecated:
since 1.41 use ChangeTagStore::updateTags()
Parameters
string | array | null$tagsToAddTags to add to the change
string | array | null$tagsToRemoveTags to remove from the change
int | null&$rc_idThe rc_id of the change to add the tags to. Pass a variable whose value is null if the rc_id is not relevant or unknown.
int | null&$rev_idThe rev_id of the change to add the tags to. Pass a variable whose value is null if the rev_id is not relevant or unknown.
int | null&$log_idThe log_id of the change to add the tags to. Pass a variable whose value is null if the log_id is not relevant or unknown.
string | null$paramsParams to put in the ct_params field of table 'change_tag' when adding tags
RecentChange | null$rcRecent change being tagged, in case the tagging accompanies the action
UserIdentity | null$userTagging user, in case the tagging is subsequent to the tagged action
Returns
array Index 0 is an array of tags actually added, index 1 is an array of tags actually removed, index 2 is an array of tags present on the revision or log entry before any changes were made
Since
1.25

Definition at line 322 of file ChangeTags.php.

References $params.

◆ updateTagsWithChecks()

static ChangeTags::updateTagsWithChecks (   $tagsToAdd,
  $tagsToRemove,
  $rc_id,
  $rev_id,
  $log_id,
  $params,
string  $reason,
Authority  $performer 
)
static

Adds and/or removes tags to/from a given change, checking whether it is allowed first, and adding a log entry afterwards.

Includes a call to ChangeTags::canUpdateTags(), so your code doesn't need to do that. However, it doesn't check whether the *_id parameters are a valid combination. That is up to you to enforce. See ApiTag::execute() for an example.

Extensions should generally avoid this function. Call ChangeTags::updateTags() instead, unless directly handling a user request to add or remove tags from an existing revision or log entry.

Parameters
array | null$tagsToAddIf none, pass [] or null
array | null$tagsToRemoveIf none, pass [] or null
int | null$rc_idThe rc_id of the change to add the tags to
int | null$rev_idThe rev_id of the change to add the tags to
int | null$log_idThe log_id of the change to add the tags to
string | null$paramsParams to put in the ct_params field of table 'change_tag' when adding tags
string$reasonComment for the log
Authority$performerwho to check permissions and give credit for the action
Returns
Status If successful, the value of this Status object will be an object (stdClass) with the following fields:
  • logId: the ID of the added log entry, or null if no log entry was added (i.e. no operation was performed)
  • addedTags: an array containing the tags that were actually added
  • removedTags: an array containing the tags that were actually removed
Since
1.25

Definition at line 522 of file ChangeTags.php.

References $params, MediaWiki\Permissions\Authority\authorizeAction(), canUpdateTags(), MediaWiki\Permissions\Authority\getUser(), and RevDelLogList\suggestTarget().

Referenced by ApiTag\processIndividual(), ChangeTagsLogList\updateChangeTagsOnAll(), and ChangeTagsRevisionList\updateChangeTagsOnAll().

Member Data Documentation

◆ BYPASS_MAX_USAGE_CHECK

const ChangeTags::BYPASS_MAX_USAGE_CHECK = 1

Flag for canDeleteTag().

Definition at line 108 of file ChangeTags.php.

Referenced by DeleteTag\execute().

◆ DISPLAY_TABLE_ALIAS

const ChangeTags::DISPLAY_TABLE_ALIAS = 'changetagdisplay'

Definition at line 122 of file ChangeTags.php.

Referenced by MediaWiki\Specials\SpecialRecentChanges\doMainQuery().

◆ REVERT_TAGS

const ChangeTags::REVERT_TAGS = [ self::TAG_ROLLBACK, self::TAG_UNDO, self::TAG_MANUAL_REVERT ]

List of tags which denote a revert of some sort.

(See also TAG_REVERTED.)

Definition at line 103 of file ChangeTags.php.

Referenced by MediaWiki\Rest\Handler\PageHistoryCountHandler\getRevertedCount(), and MediaWiki\Rest\Handler\PageHistoryHandler\run().

◆ TAG_BLANK

const ChangeTags::TAG_BLANK = 'mw-blank'

The tagged edit blanks the page (replaces it with the empty string).

Definition at line 61 of file ChangeTags.php.

◆ TAG_CHANGED_REDIRECT_TARGET

const ChangeTags::TAG_CHANGED_REDIRECT_TARGET = 'mw-changed-redirect-target'

The tagged edit changes the target of a redirect page.

Definition at line 57 of file ChangeTags.php.

◆ TAG_CONTENT_MODEL_CHANGE

const ChangeTags::TAG_CONTENT_MODEL_CHANGE = 'mw-contentmodelchange'

The tagged edit changes the content model of the page.

Definition at line 44 of file ChangeTags.php.

◆ TAG_MANUAL_REVERT

const ChangeTags::TAG_MANUAL_REVERT = 'mw-manual-revert'

The tagged edit restores the page to an earlier revision.

The associated tag data is a JSON containing the edit result (see EditResult::jsonSerialize()).

Definition at line 86 of file ChangeTags.php.

◆ TAG_NEW_REDIRECT

const ChangeTags::TAG_NEW_REDIRECT = 'mw-new-redirect'

The tagged edit creates a new redirect (either by creating a new page or turning an existing page into a redirect).

Definition at line 49 of file ChangeTags.php.

◆ TAG_REMOVED_REDIRECT

const ChangeTags::TAG_REMOVED_REDIRECT = 'mw-removed-redirect'

The tagged edit turns a redirect page into a non-redirect.

Definition at line 53 of file ChangeTags.php.

◆ TAG_REPLACE

const ChangeTags::TAG_REPLACE = 'mw-replace'

The tagged edit removes more than 90% of the content of the page.

Definition at line 65 of file ChangeTags.php.

◆ TAG_REVERTED

const ChangeTags::TAG_REVERTED = 'mw-reverted'

The tagged edit is reverted by a subsequent edit (which is tagged by one of TAG_ROLLBACK, TAG_UNDO, TAG_MANUAL_REVERT).

Multiple edits might be reverted by the same edit.

The associated tag data is a JSON containing the edit result (see EditResult::jsonSerialize()) with an extra 'revertId' field containing the revision ID of the reverting edit.

Definition at line 94 of file ChangeTags.php.

Referenced by MediaWiki\Storage\RevertedTagUpdate\doUpdate().

◆ TAG_ROLLBACK

const ChangeTags::TAG_ROLLBACK = 'mw-rollback'

The tagged edit is a rollback (undoes the previous edit and all immediately preceding edits by the same user, and was performed via the "rollback" link available to advanced users or via the rollback API).

The associated tag data is a JSON containing the edit result (see EditResult::jsonSerialize()).

Definition at line 73 of file ChangeTags.php.

◆ TAG_SERVER_SIDE_UPLOAD

const ChangeTags::TAG_SERVER_SIDE_UPLOAD = 'mw-server-side-upload'

This tagged edit was performed while importing media files using the importImages.php maintenance script.

Definition at line 98 of file ChangeTags.php.

Referenced by ImportImages\execute().

◆ TAG_UNDO

const ChangeTags::TAG_UNDO = 'mw-undo'

The tagged edit is was performed via the "undo" link.

(Usually this means that it undoes some previous edit, but the undo workflow includes an edit step so it could be anything.)

The associated tag data is a JSON containing the edit result (see EditResult::jsonSerialize()).

Definition at line 80 of file ChangeTags.php.


The documentation for this class was generated from the following file: