Go to the documentation of this file.
44 parent::__construct( $query, $moduleName,
'qp' );
45 $this->queryPages = array_values( array_diff(
47 $this->
getConfig()->
get(
'APIUselessQueryPages' )
49 $this->specialPageFactory = MediaWikiServices::getInstance()->getSpecialPageFactory();
57 $this->
run( $resultPageSet );
65 $qp = $this->specialPageFactory->getPage( $name );
69 'SpecialPageFactory failed to create special page ' . $name
75 'Special page ' . $name .
' is not a QueryPage'
84 public function run( $resultPageSet =
null ) {
89 if ( !$qp->userCanExecute( $this->getUser() ) ) {
90 $this->
dieWithError(
'apierror-specialpage-cantexecute' );
93 $r = [
'name' => $params[
'page'] ];
94 if ( $qp->isCached() ) {
95 if ( !$qp->isCacheable() ) {
96 $r[
'disabled'] =
true;
99 $ts = $qp->getCachedTimestamp();
101 $r[
'cachedtimestamp'] =
wfTimestamp( TS_ISO_8601, $ts );
103 $r[
'maxresults'] = $this->
getConfig()->get(
'QueryCacheLimit' );
106 $result->addValue( [
'query' ], $this->
getModuleName(), $r );
108 if ( $qp->isCached() && !$qp->isCacheable() ) {
113 $res = $qp->doQuery( $params[
'offset'], $params[
'limit'] + 1 );
116 foreach (
$res as $row ) {
117 if ( ++$count > $params[
'limit'] ) {
124 if ( is_null( $resultPageSet ) ) {
126 if ( isset( $row->value ) ) {
127 $data[
'value'] = $row->value;
128 if ( $qp->usesTimestamps() ) {
129 $data[
'timestamp'] =
wfTimestamp( TS_ISO_8601, $row->value );
134 foreach ( $row as $field => $value ) {
135 if ( !in_array( $field, [
'namespace',
'title',
'value',
'qc_type' ] ) ) {
136 $data[
'databaseResult'][$field] = $value;
140 $fit = $result->addValue( [
'query', $this->
getModuleName(),
'results' ],
null, $data );
149 if ( is_null( $resultPageSet ) ) {
150 $result->addIndexedTagName(
155 $resultPageSet->populateFromTitles( $titles );
161 if ( $qp->getRestriction() !=
'' ) {
190 'action=query&list=querypage&qppage=Ancientpages'
191 =>
'apihelp-query+querypage-example-ancientpages',
196 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Querypage';
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
This is the main query class.
const PARAM_REQUIRED
(boolean) Is the parameter required?
dieWithError( $msg, $code=null, $data=null, $httpCode=null)
Abort execution with an error.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getResult()
Get the result object.
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
getCacheMode( $params)
Get the cache mode for the data generated by this module.
setContinueEnumParameter( $paramName, $paramValue)
Overridden to set the generator param if in generator mode.
Query module to get the results of a QueryPage-based special page.
const PARAM_MIN
(integer) Lowest value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
string[] $queryPages
list of special page names
getHelpUrls()
Return links to more detailed help pages about the module.
const LIMIT_BIG1
Fast query, standard limit.
const PARAM_MAX
(integer) Max value allowed for the parameter, for PARAM_TYPE 'integer' and 'limit'.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Factory for handling the special page list and generating SpecialPage objects.
executeGenerator( $resultPageSet)
Execute this module as a generator.
getExamplesMessages()
Returns usage examples for this module.
SpecialPageFactory $specialPageFactory
run( $resultPageSet=null)
const LIMIT_BIG2
Fast query, apihighlimits limit.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
const PARAM_DFLT
(null|boolean|integer|string) Default value of the parameter.
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_MAX2
(integer) Max value allowed for the parameter for users with the apihighlimits right,...
__construct(ApiQuery $query, $moduleName)
static getPages()
Get a list of query page classes and their associated special pages, for periodic updates.
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.