25 parent::__construct( $query, $moduleName,
'pwp' );
39 $this->run( $resultPageSet );
46 private function run( $resultPageSet =
null ) {
49 $prop = array_fill_keys( $params[
'prop'],
true );
50 $fld_ids = isset( $prop[
'ids'] );
51 $fld_title = isset( $prop[
'title'] );
52 $fld_value = isset( $prop[
'value'] );
54 if ( $resultPageSet ===
null ) {
56 $this->
addFieldsIf( [
'page_title',
'page_namespace' ], $fld_title );
59 $this->
addFields( $resultPageSet->getPageTableFields() );
61 $this->
addTables( [
'page_props',
'page' ] );
62 $this->
addWhere(
'pp_page=page_id' );
63 $this->
addWhereFld(
'pp_propname', $params[
'propname'] );
65 $dir = ( $params[
'dir'] ==
'ascending' ) ?
'newer' :
'older';
67 if ( $params[
'continue'] ) {
73 $sort = (
$params[
'dir'] ===
'descending' ?
' DESC' :
'' );
74 $this->
addOption(
'ORDER BY',
'pp_page' . $sort );
81 $res = $this->
select( __METHOD__ );
83 if ( $fld_title && $resultPageSet ===
null ) {
87 foreach ( $res as $row ) {
88 if ( ++$count > $limit ) {
95 if ( $resultPageSet ===
null ) {
100 $vals[
'pageid'] = (int)$row->page_id;
107 $vals[
'value'] = $row->pp_value;
109 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
115 $resultPageSet->processDbRow( $row );
119 if ( $resultPageSet ===
null ) {
120 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
128 ParamValidator::PARAM_TYPE =>
'string',
129 ParamValidator::PARAM_REQUIRED =>
true,
132 ParamValidator::PARAM_DEFAULT =>
'ids|title',
133 ParamValidator::PARAM_ISMULTI =>
true,
134 ParamValidator::PARAM_TYPE => [
145 ParamValidator::PARAM_TYPE =>
'limit',
146 ParamValidator::PARAM_DEFAULT => 10,
147 IntegerDef::PARAM_MIN => 1,
152 ParamValidator::PARAM_DEFAULT =>
'ascending',
153 ParamValidator::PARAM_TYPE => [
164 'action=query&list=pageswithprop&pwppropname=displaytitle&pwpprop=ids|title|value'
165 =>
'apihelp-query+pageswithprop-example-simple',
166 'action=query&generator=pageswithprop&gpwppropname=notoc&prop=info'
167 =>
'apihelp-query+pageswithprop-example-generator',
173 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Pageswithprop';
178class_alias( ApiQueryPagesWithProp::class,
'ApiQueryPagesWithProp' );
A query module to enumerate pages that use a particular prop.
getExamplesMessages()
Returns usage examples for this module.Return value has query strings as keys, with values being eith...
__construct(ApiQuery $query, string $moduleName)
executeGenerator( $resultPageSet)
Execute this module as a generator.
getHelpUrls()
Return links to more detailed help pages about the module.1.25, returning boolean false is deprecated...
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getCacheMode( $params)
Get the cache mode for the data generated by this module.Override this in the module subclass....