$token = $wgUser->editToken( '', $this->getMain()->getRequest() );
}
+ $dir = $params['dir'];
+
// We need a custom WHERE clause that matches all titles.
if ( $mode == 'revs' ) {
$lb = new LinkBatch( $titles );
$this->addWhere( $where );
} elseif ( $mode == 'all' ) {
$this->addWhereFld( 'ar_namespace', $params['namespace'] );
- if ( !is_null( $params['from'] ) ) {
- $from = $this->getDB()->strencode( $this->titleToKey( $params['from'] ) );
- $this->addWhere( "ar_title >= '$from'" );
- }
+
+ $from = is_null( $params['from'] ) ? null : $this->titleToKey( $params['from'] );
+ $to = is_null( $params['to'] ) ? null : $this->titleToKey( $params['to'] );
+ $this->addWhereRange( 'ar_title', $dir, $from, $to );
}
if ( !is_null( $params['user'] ) ) {
$this->getDB()->addQuotes( $params['excludeuser'] ) );
}
- if ( !is_null( $params['continue'] ) && ( $mode == 'all' || $mode == 'revs' ) )
- {
+ if ( !is_null( $params['continue'] ) && ( $mode == 'all' || $mode == 'revs' ) ) {
$cont = explode( '|', $params['continue'] );
if ( count( $cont ) != 3 ) {
$this->dieUsage( 'Invalid continue param. You should pass the original value returned by the previous query', 'badcontinue' );
$ns = intval( $cont[0] );
$title = $this->getDB()->strencode( $this->titleToKey( $cont[1] ) );
$ts = $this->getDB()->strencode( $cont[2] );
- $op = ( $params['dir'] == 'newer' ? '>' : '<' );
+ $op = ( $dir == 'newer' ? '>' : '<' );
$this->addWhere( "ar_namespace $op $ns OR " .
"(ar_namespace = $ns AND " .
"(ar_title $op '$title' OR " .
if ( $mode == 'all' ) {
if ( $params['unique'] ) {
$this->addOption( 'GROUP BY', 'ar_title' );
- $this->addOption( 'ORDER BY', 'ar_title' );
} else {
- $this->addOption( 'ORDER BY', 'ar_title, ar_timestamp' );
+ $this->addOption( 'ORDER BY', 'ar_timestamp' );
}
} else {
if ( $mode == 'revs' ) {
// Sort by ns and title in the same order as timestamp for efficiency
- $this->addWhereRange( 'ar_namespace', $params['dir'], null, null );
- $this->addWhereRange( 'ar_title', $params['dir'], null, null );
+ $this->addWhereRange( 'ar_namespace', $dir, null, null );
+ $this->addWhereRange( 'ar_title', $dir, null, null );
}
- $this->addWhereRange( 'ar_timestamp', $params['dir'], $params['start'], $params['end'] );
+ $this->addWhereRange( 'ar_timestamp', $dir, $params['start'], $params['end'] );
}
$res = $this->select( __METHOD__ );
$pageMap = array(); // Maps ns&title to (fake) pageid
ApiBase::PARAM_DFLT => 'older'
),
'from' => null,
+ 'to' => null,
'continue' => null,
'unique' => false,
'user' => array(
'start' => 'The timestamp to start enumerating from (1,2)',
'end' => 'The timestamp to stop enumerating at (1,2)',
'dir' => $this->getDirectionDescription( $this->getModulePrefix(), ' (1,2)' ),
+ 'from' => 'Start listing at this title (3)',
+ 'to' => 'Stop listing at this title (3)',
'limit' => 'The maximum amount of revisions to list',
'prop' => array(
'Which properties to get',
'namespace' => 'Only list pages in this namespace (3)',
'user' => 'Only list revisions by this user',
'excludeuser' => 'Don\'t list revisions by this user',
- 'from' => 'Start listing at this title (3)',
'continue' => 'When more results are available, use this to continue (3)',
'unique' => 'List only one revision for each page (3)',
);