39 parent::__construct( $query, $moduleName,
'pwp' );
51 $this->
run( $resultPageSet );
58 private function run( $resultPageSet =
null ) {
61 $prop = array_fill_keys(
$params[
'prop'],
true );
62 $fld_ids = isset( $prop[
'ids'] );
63 $fld_title = isset( $prop[
'title'] );
64 $fld_value = isset( $prop[
'value'] );
66 if ( $resultPageSet ===
null ) {
68 $this->
addFieldsIf( [
'page_title',
'page_namespace' ], $fld_title );
71 $this->
addFields( $resultPageSet->getPageTableFields() );
73 $this->
addTables( [
'page_props',
'page' ] );
74 $this->
addWhere(
'pp_page=page_id' );
77 $dir = (
$params[
'dir'] ==
'ascending' ) ?
'newer' :
'older';
85 $sort = (
$params[
'dir'] ===
'descending' ?
' DESC' :
'' );
86 $this->
addOption(
'ORDER BY',
'pp_page' . $sort );
93 $res = $this->
select( __METHOD__ );
95 if ( $fld_title && $resultPageSet ===
null ) {
99 foreach ( $res as $row ) {
100 if ( ++$count > $limit ) {
107 if ( $resultPageSet ===
null ) {
112 $vals[
'pageid'] = (int)$row->page_id;
115 $title = Title::makeTitle( $row->page_namespace, $row->page_title );
119 $vals[
'value'] = $row->pp_value;
121 $fit = $result->addValue( [
'query', $this->
getModuleName() ],
null, $vals );
127 $resultPageSet->processDbRow( $row );
131 if ( $resultPageSet ===
null ) {
132 $result->addIndexedTagName( [
'query', $this->
getModuleName() ],
'page' );
139 ParamValidator::PARAM_TYPE =>
'string',
140 ParamValidator::PARAM_REQUIRED =>
true,
143 ParamValidator::PARAM_DEFAULT =>
'ids|title',
144 ParamValidator::PARAM_ISMULTI =>
true,
145 ParamValidator::PARAM_TYPE => [
156 ParamValidator::PARAM_TYPE =>
'limit',
157 ParamValidator::PARAM_DEFAULT => 10,
158 IntegerDef::PARAM_MIN => 1,
163 ParamValidator::PARAM_DEFAULT =>
'ascending',
164 ParamValidator::PARAM_TYPE => [
174 'action=query&list=pageswithprop&pwppropname=displaytitle&pwpprop=ids|title|value'
175 =>
'apihelp-query+pageswithprop-example-simple',
176 'action=query&generator=pageswithprop&gpwppropname=notoc&prop=info'
177 =>
'apihelp-query+pageswithprop-example-generator',
182 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Pageswithprop';
187class_alias( ApiQueryPagesWithProp::class,
'ApiQueryPagesWithProp' );
array $params
The job parameters.
A query module to enumerate pages that use a particular prop.
getExamplesMessages()
Returns usage examples for this module.
__construct(ApiQuery $query, string $moduleName)
executeGenerator( $resultPageSet)
Execute this module as a generator.
getHelpUrls()
Return links to more detailed help pages about the module.
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.