* @file
*/
-if ( !defined( 'MEDIAWIKI' ) ) {
- // Eclipse helper - will be ignored in production
- require_once( 'ApiQueryBase.php' );
-}
-
/**
* Query module to get the results of a QueryPage-based special page
*
/**
* @param $resultPageSet ApiPageSet
- * @return void
*/
public function run( $resultPageSet = null ) {
- global $wgUser;
+ global $wgQueryCacheLimit;
+
$params = $this->extractRequestParams();
$result = $this->getResult();
$qp = new $this->qpMap[$params['page']]();
- if ( !$qp->userCanExecute( $wgUser ) ) {
+ if ( !$qp->userCanExecute( $this->getUser() ) ) {
$this->dieUsageMsg( 'specialpage-cantexecute' );
}
if ( $ts ) {
$r['cachedtimestamp'] = wfTimestamp( TS_ISO_8601, $ts );
}
+ $r['maxresults'] = $wgQueryCacheLimit;
}
}
$result->addValue( array( 'query' ), $this->getModuleName(), $r );
- $res = $qp->doQuery( $params['limit'] + 1, $params['offset'] );
+ if ( $qp->isCached() && !$qp->isCacheable() ) {
+ // Disabled query page, don't run the query
+ return;
+ }
+
+ $res = $qp->doQuery( $params['offset'], $params['limit'] + 1 );
$count = 0;
$titles = array();
foreach ( $res as $row ) {
);
}
+ public function getResultProperties() {
+ return array(
+ ApiBase::PROP_ROOT => array(
+ 'name' => array(
+ ApiBase::PROP_TYPE => 'string',
+ ApiBase::PROP_NULLABLE => false
+ ),
+ 'disabled' => array(
+ ApiBase::PROP_TYPE => 'boolean',
+ ApiBase::PROP_NULLABLE => false
+ ),
+ 'cached' => array(
+ ApiBase::PROP_TYPE => 'boolean',
+ ApiBase::PROP_NULLABLE => false
+ ),
+ 'cachedtimestamp' => array(
+ ApiBase::PROP_TYPE => 'timestamp',
+ ApiBase::PROP_NULLABLE => true
+ )
+ ),
+ '' => array(
+ 'value' => 'string',
+ 'timestamp' => array(
+ ApiBase::PROP_TYPE => 'timestamp',
+ ApiBase::PROP_NULLABLE => true
+ ),
+ 'ns' => 'namespace',
+ 'title' => 'string'
+ )
+ );
+ }
+
public function getDescription() {
return 'Get a list provided by a QueryPage-based special page';
}
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
+ array( 'specialpage-cantexecute' )
) );
}
- protected function getExamples() {
+ public function getExamples() {
return array(
'api.php?action=query&list=querypage&qppage=Ancientpages'
);