MediaWiki master
|
Read-write access to the change_tags table. More...
Public Member Functions | |
__construct (IConnectionProvider $dbProvider, NameTableStore $changeTagDefStore, WANObjectCache $wanCache, HookContainer $hookContainer, LoggerInterface $logger, UserFactory $userFactory, ServiceOptions $options) | |
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. | |
defineTag ( $tag) | |
Set ctd_user_defined = 1 in change_tag_def without checking that the tag name is valid. | |
deleteTagEverywhere ( $tag) | |
Permanently removes all traces of a tag from the DB. | |
getCoreDefinedTags () | |
Expose the codebase-level defined software tags. | |
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. | |
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. | |
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. | |
listDefinedTags () | |
Basically lists defined tags which count even if they aren't applied to anything. | |
listExplicitlyDefinedTags () | |
Lists tags explicitly defined in the change_tag_def table of the database. | |
listSoftwareActivatedTags () | |
Lists those tags which core or extensions report as being "active". | |
listSoftwareDefinedTags () | |
Lists tags defined by core or extensions using the ListDefinedTags hook. | |
logTagManagementAction (string $action, string $tag, string $reason, UserIdentity $user, $tagCount=null, array $logEntryTags=[]) | |
Writes a tag action into the tag management log. | |
makeTagSummarySubquery ( $tables) | |
Make the tag summary subquery based on the given tables and return it. | |
modifyDisplayQuery (&$tables, &$fields, &$conds, &$join_conds, &$options, $filter_tag='', bool $exclude=false) | |
Applies all tags-related changes to a query. | |
modifyDisplayQueryBuilder (SelectQueryBuilder $queryBuilder, $table, $filter_tag='', bool $exclude=false) | |
Applies all tags-related changes to a query builder object. | |
purgeTagCacheAll () | |
Invalidates the short-term cache of defined tags used by the list*DefinedTags functions, as well as the tag statistics cache. | |
tagUsageStatistics () | |
Returns a map of any tags used on the wiki to number of edits tagged with them, ordered descending by the hitcount. | |
undefineTag ( $tag) | |
Update ctd_user_defined = 0 field in change_tag_def. | |
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. | |
Public Attributes | |
const | CONSTRUCTOR_OPTIONS |
const | DISPLAY_TABLE_ALIAS = 'changetagdisplay' |
Read-write access to the change_tags table.
Definition at line 50 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::__construct | ( | IConnectionProvider | $dbProvider, |
NameTableStore | $changeTagDefStore, | ||
WANObjectCache | $wanCache, | ||
HookContainer | $hookContainer, | ||
LoggerInterface | $logger, | ||
UserFactory | $userFactory, | ||
ServiceOptions | $options ) |
Definition at line 99 of file ChangeTagsStore.php.
References MediaWiki\Config\ServiceOptions\assertRequiredOptions().
MediaWiki\ChangeTags\ChangeTagsStore::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.
string | string[] | $tags | Tags to add to the change |
int | null | $rc_id | The rc_id of the change to add the tags to |
int | null | $rev_id | The rev_id of the change to add the tags to |
int | null | $log_id | The log_id of the change to add the tags to |
string | null | $params | Params to put in the ct_params field of table 'change_tag' |
RecentChange | null | $rc | Recent change, in case the tagging accompanies the action (this should normally be the case) |
Definition at line 736 of file ChangeTagsStore.php.
References $params.
MediaWiki\ChangeTags\ChangeTagsStore::defineTag | ( | $tag | ) |
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.
string | $tag | Tag to create |
Definition at line 238 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::deleteTagEverywhere | ( | $tag | ) |
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.
string | $tag | Tag to remove |
Definition at line 333 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::getCoreDefinedTags | ( | ) |
Expose the codebase-level defined software tags.
No filtering is available for this function.
Definition at line 150 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::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.
bool | $all | If true, return all valid defined tags. Otherwise, return only enabled ones. |
Definition at line 126 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::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.
IReadableDatabase | $db | the database to query |
int | null | $rc_id | |
int | null | $rev_id | |
int | null | $log_id |
Definition at line 498 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::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.
IReadableDatabase | $db | the database to query |
int | null | $rc_id | |
int | null | $rev_id | |
int | null | $log_id |
Definition at line 165 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::listDefinedTags | ( | ) |
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()
Definition at line 509 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::listExplicitlyDefinedTags | ( | ) |
Lists tags explicitly defined in the change_tag_def
table of the database.
Tries memcached first.
Definition at line 428 of file ChangeTagsStore.php.
References Wikimedia\Rdbms\IConnectionProvider\getReplicaDatabase().
MediaWiki\ChangeTags\ChangeTagsStore::listSoftwareActivatedTags | ( | ) |
Lists those tags which core or extensions report as being "active".
Definition at line 749 of file ChangeTagsStore.php.
References Wikimedia\Rdbms\IConnectionProvider\getReplicaDatabase(), and MediaWiki\HookContainer\HookRunner\onChangeTagsListActive().
MediaWiki\ChangeTags\ChangeTagsStore::listSoftwareDefinedTags | ( | ) |
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.
Definition at line 464 of file ChangeTagsStore.php.
References Wikimedia\Rdbms\IConnectionProvider\getReplicaDatabase(), and MediaWiki\HookContainer\HookRunner\onListDefinedTags().
MediaWiki\ChangeTags\ChangeTagsStore::logTagManagementAction | ( | string | $action, |
string | $tag, | ||
string | $reason, | ||
UserIdentity | $user, | ||
$tagCount = null, | |||
array | $logEntryTags = [] ) |
Writes a tag action into the tag management log.
string | $action | |
string | $tag | |
string | $reason | |
UserIdentity | $user | Who to attribute the action to |
int | null | $tagCount | For deletion only, how many usages the tag had before it was deleted. |
array | $logEntryTags | Change tags to apply to the entry that will be created in the tag management log |
Definition at line 296 of file ChangeTagsStore.php.
References $params.
MediaWiki\ChangeTags\ChangeTagsStore::makeTagSummarySubquery | ( | $tables | ) |
Make the tag summary subquery based on the given tables and return it.
string | array | $tables | Table names, see Database::select |
Definition at line 204 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::modifyDisplayQuery | ( | & | $tables, |
& | $fields, | ||
& | $conds, | ||
& | $join_conds, | ||
& | $options, | ||
$filter_tag = '', | |||
bool | $exclude = false ) |
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.
string | array | &$tables | Table names, see Database::select |
string | array | &$fields | Fields used in query, see Database::select |
string | array | &$conds | Conditions used in query, see Database::select |
array | &$join_conds | Join conditions, see Database::select |
string | array | &$options | Options, see Database::select |
string | array | false | null | $filter_tag | Tag(s) to select on (OR) |
bool | $exclude | If true, exclude tag(s) from $filter_tag (NOR) |
Definition at line 798 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::modifyDisplayQueryBuilder | ( | SelectQueryBuilder | $queryBuilder, |
$table, | |||
$filter_tag = '', | |||
bool | $exclude = false ) |
Applies all tags-related changes to a query builder object.
Handles selecting tags, and filtering.
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.
SelectQueryBuilder | $queryBuilder | Query builder to add the join |
string | $table | Table name. Must be either of 'recentchanges', 'logging', 'revision', or 'archive' |
string | array | false | null | $filter_tag | Tag(s) to select on (OR) |
bool | $exclude | If true, exclude tag(s) from $filter_tag (NOR) |
Definition at line 893 of file ChangeTagsStore.php.
References Wikimedia\Rdbms\SelectQueryBuilder\distinct(), Wikimedia\Rdbms\SelectQueryBuilder\field(), Wikimedia\Rdbms\JoinGroupBase\join(), Wikimedia\Rdbms\JoinGroupBase\leftJoin(), and Wikimedia\Rdbms\SelectQueryBuilder\where().
MediaWiki\ChangeTags\ChangeTagsStore::purgeTagCacheAll | ( | ) |
Invalidates the short-term cache of defined tags used by the list*DefinedTags functions, as well as the tag statistics cache.
Definition at line 374 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::tagUsageStatistics | ( | ) |
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.
Definition at line 389 of file ChangeTagsStore.php.
References Wikimedia\Rdbms\IConnectionProvider\getReplicaDatabase().
MediaWiki\ChangeTags\ChangeTagsStore::undefineTag | ( | $tag | ) |
Update ctd_user_defined = 0 field in change_tag_def.
The tag may remain in use by extensions, and may still show up as 'defined' if an extension is setting it from the ListDefinedTags hook.
string | $tag | Tag to remove |
Definition at line 264 of file ChangeTagsStore.php.
MediaWiki\ChangeTags\ChangeTagsStore::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.
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.
string | array | null | $tagsToAdd | Tags to add to the change |
string | array | null | $tagsToRemove | Tags to remove from the change |
int | null | &$rc_id | The 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_id | The 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_id | The 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 | $params | Params to put in the ct_params field of table 'change_tag' when adding tags |
RecentChange | null | $rc | Recent change being tagged, in case the tagging accompanies the action |
UserIdentity | null | $user | Tagging user, in case the tagging is subsequent to the tagged action |
Definition at line 542 of file ChangeTagsStore.php.
References $params.
const MediaWiki\ChangeTags\ChangeTagsStore::CONSTRUCTOR_OPTIONS |
Definition at line 67 of file ChangeTagsStore.php.
const MediaWiki\ChangeTags\ChangeTagsStore::DISPLAY_TABLE_ALIAS = 'changetagdisplay' |
Definition at line 62 of file ChangeTagsStore.php.