summaryrefslogtreecommitdiff
path: root/includes/api/ApiQueryAllPages.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiQueryAllPages.php')
-rw-r--r--includes/api/ApiQueryAllPages.php63
1 files changed, 28 insertions, 35 deletions
diff --git a/includes/api/ApiQueryAllPages.php b/includes/api/ApiQueryAllPages.php
index d95980c2..b7bd65a5 100644
--- a/includes/api/ApiQueryAllPages.php
+++ b/includes/api/ApiQueryAllPages.php
@@ -31,7 +31,7 @@
*/
class ApiQueryAllPages extends ApiQueryGeneratorBase {
- public function __construct( $query, $moduleName ) {
+ public function __construct( ApiQuery $query, $moduleName ) {
parent::__construct( $query, $moduleName, 'ap' );
}
@@ -44,19 +44,23 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
}
/**
- * @param $resultPageSet ApiPageSet
+ * @param ApiPageSet $resultPageSet
* @return void
*/
public function executeGenerator( $resultPageSet ) {
if ( $resultPageSet->isResolvingRedirects() ) {
- $this->dieUsage( 'Use "gapfilterredir=nonredirects" option instead of "redirects" when using allpages as a generator', 'params' );
+ $this->dieUsage(
+ 'Use "gapfilterredir=nonredirects" option instead of "redirects" ' .
+ 'when using allpages as a generator',
+ 'params'
+ );
}
$this->run( $resultPageSet );
}
/**
- * @param $resultPageSet ApiPageSet
+ * @param ApiPageSet $resultPageSet
* @return void
*/
private function run( $resultPageSet = null ) {
@@ -83,12 +87,18 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
$this->addWhereFld( 'page_namespace', $params['namespace'] );
$dir = ( $params['dir'] == 'descending' ? 'older' : 'newer' );
- $from = ( is_null( $params['from'] ) ? null : $this->titlePartToKey( $params['from'] ) );
- $to = ( is_null( $params['to'] ) ? null : $this->titlePartToKey( $params['to'] ) );
+ $from = ( $params['from'] === null
+ ? null
+ : $this->titlePartToKey( $params['from'], $params['namespace'] ) );
+ $to = ( $params['to'] === null
+ ? null
+ : $this->titlePartToKey( $params['to'], $params['namespace'] ) );
$this->addWhereRange( 'page_title', $dir, $from, $to );
if ( isset( $params['prefix'] ) ) {
- $this->addWhere( 'page_title' . $db->buildLike( $this->titlePartToKey( $params['prefix'] ), $db->anyString() ) );
+ $this->addWhere( 'page_title' . $db->buildLike(
+ $this->titlePartToKey( $params['prefix'], $params['namespace'] ),
+ $db->anyString() ) );
}
if ( is_null( $resultPageSet ) ) {
@@ -145,7 +155,6 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
}
$this->addOption( 'DISTINCT' );
-
} elseif ( isset( $params['prlevel'] ) ) {
$this->dieUsage( 'prlevel may not be used without prtype', 'params' );
}
@@ -186,8 +195,9 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
$count = 0;
$result = $this->getResult();
foreach ( $res as $row ) {
- if ( ++ $count > $limit ) {
- // We've reached the one extra which shows that there are additional pages to be had. Stop here...
+ if ( ++$count > $limit ) {
+ // We've reached the one extra which shows that there are
+ // additional pages to be had. Stop here...
$this->setContinueEnumParameter( 'continue', $row->page_title );
break;
}
@@ -215,8 +225,6 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
}
public function getAllowedParams() {
- global $wgRestrictionLevels;
-
return array(
'from' => null,
'continue' => null,
@@ -245,7 +253,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
ApiBase::PARAM_ISMULTI => true
),
'prlevel' => array(
- ApiBase::PARAM_TYPE => $wgRestrictionLevels,
+ ApiBase::PARAM_TYPE => $this->getConfig()->get( 'RestrictionLevels' ),
ApiBase::PARAM_ISMULTI => true
),
'prfiltercascade' => array(
@@ -291,6 +299,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
public function getParamDescription() {
$p = $this->getModulePrefix();
+
return array(
'from' => 'The page title to start enumerating from',
'continue' => 'When more results are available, use this to continue',
@@ -303,7 +312,8 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
'maxsize' => 'Limit to pages with at most this many bytes',
'prtype' => 'Limit to protected pages only',
'prlevel' => "The protection level (must be used with {$p}prtype= parameter)",
- 'prfiltercascade' => "Filter protections based on cascadingness (ignored when {$p}prtype isn't set)",
+ 'prfiltercascade'
+ => "Filter protections based on cascadingness (ignored when {$p}prtype isn't set)",
'filterlanglinks' => array(
'Filter based on whether a page has langlinks',
'Note that this may not consider langlinks added by extensions.',
@@ -318,25 +328,8 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
);
}
- public function getResultProperties() {
- return array(
- '' => array(
- 'pageid' => 'integer',
- 'ns' => 'namespace',
- 'title' => 'string'
- )
- );
- }
-
public function getDescription() {
- return 'Enumerate all pages sequentially in a given namespace';
- }
-
- public function getPossibleErrors() {
- return array_merge( parent::getPossibleErrors(), array(
- array( 'code' => 'params', 'info' => 'Use "gapfilterredir=nonredirects" option instead of "redirects" when using allpages as a generator' ),
- array( 'code' => 'params', 'info' => 'prlevel may not be used without prtype' ),
- ) );
+ return 'Enumerate all pages sequentially in a given namespace.';
}
public function getExamples() {
@@ -349,9 +342,9 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
'Using as Generator',
'Show info about 4 pages starting at the letter "T"',
),
- 'api.php?action=query&generator=allpages&gaplimit=2&gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content' => array(
- 'Show content of first 2 non-redirect pages beginning at "Re"',
- )
+ 'api.php?action=query&generator=allpages&gaplimit=2&' .
+ 'gapfilterredir=nonredirects&gapfrom=Re&prop=revisions&rvprop=content'
+ => array( 'Show content of first 2 non-redirect pages beginning at "Re"' )
);
}