MediaWiki REL1_30
ApiQueryPagePropNames.php
Go to the documentation of this file.
1<?php
33
34 public function __construct( ApiQuery $query, $moduleName ) {
35 parent::__construct( $query, $moduleName, 'ppn' );
36 }
37
38 public function getCacheMode( $params ) {
39 return 'public';
40 }
41
42 public function execute() {
44
45 $this->addTables( 'page_props' );
46 $this->addFields( 'pp_propname' );
47 $this->addOption( 'DISTINCT' );
48 $this->addOption( 'ORDER BY', 'pp_propname' );
49
50 if ( $params['continue'] ) {
51 $cont = explode( '|', $params['continue'] );
52 $this->dieContinueUsageIf( count( $cont ) != 1 );
53
54 // Add a WHERE clause
55 $this->addWhereRange( 'pp_propname', 'newer', $cont[0], null );
56 }
57
58 $limit = $params['limit'];
59
60 // mysql has issues with limit in loose index T115825
61 if ( $this->getDB()->getType() !== 'mysql' ) {
62 $this->addOption( 'LIMIT', $limit + 1 );
63 }
64
65 $result = $this->getResult();
66 $count = 0;
67 foreach ( $this->select( __METHOD__ ) as $row ) {
68 if ( ++$count > $limit ) {
69 // We've reached the one extra which shows that there are
70 // additional pages to be had. Stop here...
71 $this->setContinueEnumParameter( 'continue', $row->pp_propname );
72 break;
73 }
74
75 $vals = [];
76 $vals['propname'] = $row->pp_propname;
77 $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $vals );
78 if ( !$fit ) {
79 $this->setContinueEnumParameter( 'continue', $row->pp_propname );
80 break;
81 }
82 }
83
84 $result->addIndexedTagName( [ 'query', $this->getModuleName() ], 'p' );
85 }
86
87 public function getAllowedParams() {
88 return [
89 'continue' => [
90 ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
91 ],
92 'limit' => [
93 ApiBase::PARAM_TYPE => 'limit',
98 ],
99 ];
100 }
101
102 protected function getExamplesMessages() {
103 return [
104 'action=query&list=pagepropnames'
105 => 'apihelp-query+pagepropnames-example-simple',
106 ];
107 }
108
109 public function getHelpUrls() {
110 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Pagepropnames';
111 }
112}
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
Definition ApiBase.php:100
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition ApiBase.php:94
dieContinueUsageIf( $condition)
Die with the 'badcontinue' error.
Definition ApiBase.php:2026
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
Definition ApiBase.php:91
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
Definition ApiBase.php:52
extractRequestParams( $parseLimit=true)
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:740
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
Definition ApiBase.php:103
const LIMIT_BIG1
Fast query, standard limit.
Definition ApiBase.php:225
getResult()
Get the result object.
Definition ApiBase.php:632
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
Definition ApiBase.php:128
const LIMIT_BIG2
Fast query, apihighlimits limit.
Definition ApiBase.php:227
getModuleName()
Get the name of the module being executed by this instance.
Definition ApiBase.php:512
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)
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:40
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like select() and insert() are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition hooks.txt:1610
$params