37 parent::__construct( $query, $moduleName,
'tg' );
38 $this->changeTagsStore = $changeTagsStore;
44 $prop = array_fill_keys(
$params[
'prop'],
true );
46 $fld_displayname = isset( $prop[
'displayname'] );
47 $fld_description = isset( $prop[
'description'] );
48 $fld_hitcount = isset( $prop[
'hitcount'] );
49 $fld_defined = isset( $prop[
'defined'] );
50 $fld_source = isset( $prop[
'source'] );
51 $fld_active = isset( $prop[
'active'] );
56 $softwareDefinedTags = array_fill_keys( $this->changeTagsStore->listSoftwareDefinedTags(), 0 );
57 $explicitlyDefinedTags = array_fill_keys( $this->changeTagsStore->listExplicitlyDefinedTags(), 0 );
58 $softwareActivatedTags = array_fill_keys( $this->changeTagsStore->listSoftwareActivatedTags(), 0 );
60 $tagHitcounts = array_merge(
62 $explicitlyDefinedTags,
63 $this->changeTagsStore->tagUsageStatistics()
65 $tags = array_keys( $tagHitcounts );
67 # Fetch defined tags that aren't past the continuation
68 if (
$params[
'continue'] !==
null ) {
70 $tags = array_filter( $tags,
static function ( $v ) use ( $cont ) {
75 # Now make sure the array is sorted for proper continuation
79 foreach ( $tags as $tagName ) {
80 if ( ++$count > $limit ) {
86 $tag[
'name'] = $tagName;
88 if ( $fld_displayname ) {
92 if ( $fld_description ) {
93 $msg = $this->
msg(
"tag-$tagName-description" );
94 $tag[
'description'] = $msg->exists() ? $msg->text() :
'';
97 if ( $fld_hitcount ) {
98 $tag[
'hitcount'] = (int)$tagHitcounts[$tagName];
101 $isSoftware = isset( $softwareDefinedTags[$tagName] );
102 $isExplicit = isset( $explicitlyDefinedTags[$tagName] );
104 if ( $fld_defined ) {
105 $tag[
'defined'] = $isSoftware || $isExplicit;
111 $tag[
'source'][] =
'software';
113 $tag[
'source'][] =
'extension';
116 $tag[
'source'][] =
'manual';
121 $tag[
'active'] = $isExplicit || isset( $softwareActivatedTags[$tagName] );
124 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $tag );
131 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'tag' );
144 ParamValidator::PARAM_DEFAULT => 10,
145 ParamValidator::PARAM_TYPE =>
'limit',
146 IntegerDef::PARAM_MIN => 1,
151 ParamValidator::PARAM_DEFAULT =>
'',
152 ParamValidator::PARAM_TYPE => [
160 ParamValidator::PARAM_ISMULTI =>
true,
168 'action=query&list=tags&tgprop=displayname|description|hitcount|defined'
169 =>
'apihelp-query+tags-example-simple',
174 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Tags';
array $params
The job parameters.
const PARAM_HELP_MSG_PER_VALUE
((string|array|Message)[]) When PARAM_TYPE is an array, or 'string' with PARAM_ISMULTI,...
const LIMIT_BIG1
Fast query, standard limit.
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const LIMIT_BIG2
Fast query, apihighlimits limit.
getModuleName()
Get the name of the module being executed by this instance.
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
This is the main query class.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()