summaryrefslogtreecommitdiff
path: root/includes/api/ApiQueryProtectedTitles.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiQueryProtectedTitles.php')
-rw-r--r--includes/api/ApiQueryProtectedTitles.php88
1 files changed, 40 insertions, 48 deletions
diff --git a/includes/api/ApiQueryProtectedTitles.php b/includes/api/ApiQueryProtectedTitles.php
index 222ad074..4c88be7a 100644
--- a/includes/api/ApiQueryProtectedTitles.php
+++ b/includes/api/ApiQueryProtectedTitles.php
@@ -31,7 +31,7 @@
*/
class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
- public function __construct( $query, $moduleName ) {
+ public function __construct( ApiQuery $query, $moduleName ) {
parent::__construct( $query, $moduleName, 'pt' );
}
@@ -44,7 +44,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
}
/**
- * @param $resultPageSet ApiPageSet
+ * @param ApiPageSet $resultPageSet
* @return void
*/
private function run( $resultPageSet = null ) {
@@ -63,6 +63,27 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
$this->addWhereFld( 'pt_namespace', $params['namespace'] );
$this->addWhereFld( 'pt_create_perm', $params['level'] );
+ // Include in ORDER BY for uniqueness
+ $this->addWhereRange( 'pt_namespace', $params['dir'], null, null );
+ $this->addWhereRange( 'pt_title', $params['dir'], null, null );
+
+ if ( !is_null( $params['continue'] ) ) {
+ $cont = explode( '|', $params['continue'] );
+ $this->dieContinueUsageIf( count( $cont ) != 3 );
+ $op = ( $params['dir'] === 'newer' ? '>' : '<' );
+ $db = $this->getDB();
+ $continueTimestamp = $db->addQuotes( $db->timestamp( $cont[0] ) );
+ $continueNs = (int)$cont[1];
+ $this->dieContinueUsageIf( $continueNs != $cont[1] );
+ $continueTitle = $db->addQuotes( $cont[2] );
+ $this->addWhere( "pt_timestamp $op $continueTimestamp OR " .
+ "(pt_timestamp = $continueTimestamp AND " .
+ "(pt_namespace $op $continueNs OR " .
+ "(pt_namespace = $continueNs AND " .
+ "pt_title $op= $continueTitle)))"
+ );
+ }
+
if ( isset( $prop['user'] ) ) {
$this->addTables( 'user' );
$this->addFields( 'user_name' );
@@ -80,9 +101,12 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
$titles = array();
foreach ( $res as $row ) {
- if ( ++ $count > $params['limit'] ) {
- // We've reached the one extra which shows that there are additional pages to be had. Stop here...
- $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->pt_timestamp ) );
+ if ( ++$count > $params['limit'] ) {
+ // We've reached the one extra which shows that there are
+ // additional pages to be had. Stop here...
+ $this->setContinueEnumParameter( 'continue',
+ "$row->pt_timestamp|$row->pt_namespace|$row->pt_title"
+ );
break;
}
@@ -121,8 +145,9 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
$fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $vals );
if ( !$fit ) {
- $this->setContinueEnumParameter( 'start',
- wfTimestamp( TS_ISO_8601, $row->pt_timestamp ) );
+ $this->setContinueEnumParameter( 'continue',
+ "$row->pt_timestamp|$row->pt_namespace|$row->pt_title"
+ );
break;
}
} else {
@@ -131,7 +156,10 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
}
if ( is_null( $resultPageSet ) ) {
- $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), $this->getModulePrefix() );
+ $result->setIndexedTagName_internal(
+ array( 'query', $this->getModuleName() ),
+ $this->getModulePrefix()
+ );
} else {
$resultPageSet->populateFromTitles( $titles );
}
@@ -147,7 +175,6 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
}
public function getAllowedParams() {
- global $wgRestrictionLevels;
return array(
'namespace' => array(
ApiBase::PARAM_ISMULTI => true,
@@ -155,7 +182,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
),
'level' => array(
ApiBase::PARAM_ISMULTI => true,
- ApiBase::PARAM_TYPE => array_diff( $wgRestrictionLevels, array( '' ) )
+ ApiBase::PARAM_TYPE => array_diff( $this->getConfig()->get( 'RestrictionLevels' ), array( '' ) )
),
'limit' => array(
ApiBase::PARAM_DFLT => 10,
@@ -190,6 +217,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
'level'
)
),
+ 'continue' => null,
);
}
@@ -211,48 +239,12 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
' level - Adds the protection level',
),
'level' => 'Only list titles with these protection levels',
- );
- }
-
- public function getResultProperties() {
- global $wgRestrictionLevels;
- return array(
- '' => array(
- 'ns' => 'namespace',
- 'title' => 'string'
- ),
- 'timestamp' => array(
- 'timestamp' => 'timestamp'
- ),
- 'user' => array(
- 'user' => array(
- ApiBase::PROP_TYPE => 'string',
- ApiBase::PROP_NULLABLE => true
- ),
- 'userid' => 'integer'
- ),
- 'userid' => array(
- 'userid' => 'integer'
- ),
- 'comment' => array(
- 'comment' => 'string'
- ),
- 'parsedcomment' => array(
- 'parsedcomment' => 'string'
- ),
- 'expiry' => array(
- 'expiry' => 'timestamp'
- ),
- 'level' => array(
- 'level' => array(
- ApiBase::PROP_TYPE => array_diff( $wgRestrictionLevels, array( '' ) )
- )
- )
+ 'continue' => 'When more results are available, use this to continue',
);
}
public function getDescription() {
- return 'List all titles protected from creation';
+ return 'List all titles protected from creation.';
}
public function getExamples() {