MediaWiki REL1_34
ApiQueryPagePropNames.php
Go to the documentation of this file.
1<?php
31
32 public function __construct( ApiQuery $query, $moduleName ) {
33 parent::__construct( $query, $moduleName, 'ppn' );
34 }
35
36 public function getCacheMode( $params ) {
37 return 'public';
38 }
39
40 public function execute() {
41 $params = $this->extractRequestParams();
42
43 $this->addTables( 'page_props' );
44 $this->addFields( 'pp_propname' );
45 $this->addOption( 'DISTINCT' );
46 $this->addOption( 'ORDER BY', 'pp_propname' );
47
48 if ( $params['continue'] ) {
49 $cont = explode( '|', $params['continue'] );
50 $this->dieContinueUsageIf( count( $cont ) != 1 );
51
52 // Add a WHERE clause
53 $this->addWhereRange( 'pp_propname', 'newer', $cont[0], null );
54 }
55
56 $limit = $params['limit'];
57
58 // mysql has issues with limit in loose index T115825
59 if ( $this->getDB()->getType() !== 'mysql' ) {
60 $this->addOption( 'LIMIT', $limit + 1 );
61 }
62
63 $result = $this->getResult();
64 $count = 0;
65 foreach ( $this->select( __METHOD__ ) as $row ) {
66 if ( ++$count > $limit ) {
67 // We've reached the one extra which shows that there are
68 // additional pages to be had. Stop here...
69 $this->setContinueEnumParameter( 'continue', $row->pp_propname );
70 break;
71 }
72
73 $vals = [];
74 $vals['propname'] = $row->pp_propname;
75 $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $vals );
76 if ( !$fit ) {
77 $this->setContinueEnumParameter( 'continue', $row->pp_propname );
78 break;
79 }
80 }
81
82 $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'p' );
83 }
84
85 public function getAllowedParams() {
86 return [
87 'continue' => [
88 ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
89 ],
90 'limit' => [
91 ApiBase::PARAM_TYPE => 'limit',
96 ],
97 ];
98 }
99
100 protected function getExamplesMessages() {
101 return [
102 'action=query&list=pagepropnames'
103 => 'apihelp-query+pagepropnames-example-simple',
104 ];
105 }
106
107 public function getHelpUrls() {
108 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Pagepropnames';
109 }
110}
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
Definition ApiBase.php:103
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition ApiBase.php:97
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
Definition ApiBase.php:2208
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition ApiBase.php:94
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition ApiBase.php:55
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition ApiBase.php:106
const LIMIT_BIG1
Fast query, standard limit.
Definition ApiBase.php:259
getResult()
Get the result object.
Definition ApiBase.php:640
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:761
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:131
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition ApiBase.php:261
getModuleName()
Get the name of the module being executed by this instance.
Definition ApiBase.php:520
This is a base class for all Query modules.
setContinueEnumParameter( $paramName, $paramValue)
Set a query-continue value.
addWhereRange( $field, $dir, $start, $end, $sort=true)
Add a WHERE clause corresponding to a range, and an ORDER BY clause to sort in the right direction.
addFields( $value)
Add a set of fields to select to the internal array.
addOption( $name, $value=null)
Add an option such as LIMIT or USE INDEX.
addTables( $tables, $alias=null)
Add a set of tables to the internal array.
getDB()
Get the Query database connection (read-only)
select( $method, $extraQuery=[], array &$hookData=null)
Execute a SELECT query based on the values in the internal arrays.
A query module to list used page props.
__construct(ApiQuery $query, $moduleName)
getExamplesMessages()
Returns usage examples for this module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getCacheMode( $params)
Get the cache mode for the data generated by this module.
This is the main query class.
Definition ApiQuery.php:37