summaryrefslogtreecommitdiff
path: root/includes/api/ApiQueryRevisions.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiQueryRevisions.php')
-rw-r--r--includes/api/ApiQueryRevisions.php98
1 files changed, 89 insertions, 9 deletions
diff --git a/includes/api/ApiQueryRevisions.php b/includes/api/ApiQueryRevisions.php
index fa58bdf0..b89a8ea9 100644
--- a/includes/api/ApiQueryRevisions.php
+++ b/includes/api/ApiQueryRevisions.php
@@ -4,7 +4,7 @@
*
* Created on Sep 7, 2006
*
- * Copyright © 2006 Yuri Astrakhan <Firstname><Lastname>@gmail.com
+ * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com"
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -224,6 +224,13 @@ class ApiQueryRevisions extends ApiQueryBase {
}
}
+ // add user name, if needed
+ if ( $this->fld_user ) {
+ $this->addTables( 'user' );
+ $this->addJoinConds( array( 'user' => Revision::userJoinCond() ) );
+ $this->addFields( Revision::selectUserFields() );
+ }
+
// Bug 24166 - API error when using rvprop=tags
$this->addTables( 'revision' );
@@ -241,6 +248,16 @@ class ApiQueryRevisions extends ApiQueryBase {
$this->dieUsage( 'user and excludeuser cannot be used together', 'badparams' );
}
+ // Continuing effectively uses startid. But we can't use rvstartid
+ // directly, because there is no way to tell the client to ''not''
+ // send rvstart if it sent it in the original query. So instead we
+ // send the continuation startid as rvcontinue, and ignore both
+ // rvstart and rvstartid when that is supplied.
+ if ( !is_null( $params['continue'] ) ) {
+ $params['startid'] = $params['continue'];
+ unset( $params['start'] );
+ }
+
// This code makes an assumption that sorting by rev_id and rev_timestamp produces
// the same result. This way users may request revisions starting at a given time,
// but to page through results use the rev_id returned after each page.
@@ -290,7 +307,7 @@ class ApiQueryRevisions extends ApiQueryBase {
$this->addWhereFld( 'rev_id', array_keys( $revs ) );
if ( !is_null( $params['continue'] ) ) {
- $this->addWhere( "rev_id >= '" . intval( $params['continue'] ) . "'" );
+ $this->addWhere( 'rev_id >= ' . intval( $params['continue'] ) );
}
$this->addOption( 'ORDER BY', 'rev_id' );
@@ -322,12 +339,15 @@ class ApiQueryRevisions extends ApiQueryBase {
$pageid = intval( $cont[0] );
$revid = intval( $cont[1] );
$this->addWhere(
- "rev_page > '$pageid' OR " .
- "(rev_page = '$pageid' AND " .
- "rev_id >= '$revid')"
+ "rev_page > $pageid OR " .
+ "(rev_page = $pageid AND " .
+ "rev_id >= $revid)"
);
}
- $this->addOption( 'ORDER BY', 'rev_page, rev_id' );
+ $this->addOption( 'ORDER BY', array(
+ 'rev_page',
+ 'rev_id'
+ ));
// assumption testing -- we should never get more then $pageCount rows.
$limit = $pageCount;
@@ -347,14 +367,14 @@ class ApiQueryRevisions extends ApiQueryBase {
if ( !$enumRevMode ) {
ApiBase::dieDebug( __METHOD__, 'Got more rows then expected' ); // bug report
}
- $this->setContinueEnumParameter( 'startid', intval( $row->rev_id ) );
+ $this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) );
break;
}
$fit = $this->addPageSubItem( $row->rev_page, $this->extractRowInfo( $row ), 'rev' );
if ( !$fit ) {
if ( $enumRevMode ) {
- $this->setContinueEnumParameter( 'startid', intval( $row->rev_id ) );
+ $this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) );
} elseif ( $revCount > 0 ) {
$this->setContinueEnumParameter( 'continue', intval( $row->rev_id ) );
} else {
@@ -528,7 +548,7 @@ class ApiQueryRevisions extends ApiQueryBase {
return 'private';
}
if ( !is_null( $params['prop'] ) && in_array( 'parsedcomment', $params['prop'] ) ) {
- // formatComment() calls wfMsg() among other things
+ // formatComment() calls wfMessage() among other things
return 'anon-public-user-private';
}
return 'public';
@@ -638,6 +658,66 @@ class ApiQueryRevisions extends ApiQueryBase {
);
}
+ public function getResultProperties() {
+ $props = array(
+ '' => array(),
+ 'ids' => array(
+ 'revid' => 'integer',
+ 'parentid' => array(
+ ApiBase::PROP_TYPE => 'integer',
+ ApiBase::PROP_NULLABLE => true
+ )
+ ),
+ 'flags' => array(
+ 'minor' => 'boolean'
+ ),
+ 'user' => array(
+ 'userhidden' => 'boolean',
+ 'user' => 'string',
+ 'anon' => 'boolean'
+ ),
+ 'userid' => array(
+ 'userhidden' => 'boolean',
+ 'userid' => 'integer',
+ 'anon' => 'boolean'
+ ),
+ 'timestamp' => array(
+ 'timestamp' => 'timestamp'
+ ),
+ 'size' => array(
+ 'size' => 'integer'
+ ),
+ 'sha1' => array(
+ 'sha1' => 'string'
+ ),
+ 'comment' => array(
+ 'commenthidden' => 'boolean',
+ 'comment' => array(
+ ApiBase::PROP_TYPE => 'string',
+ ApiBase::PROP_NULLABLE => true
+ )
+ ),
+ 'parsedcomment' => array(
+ 'commenthidden' => 'boolean',
+ 'parsedcomment' => array(
+ ApiBase::PROP_TYPE => 'string',
+ ApiBase::PROP_NULLABLE => true
+ )
+ ),
+ 'content' => array(
+ '*' => array(
+ ApiBase::PROP_TYPE => 'string',
+ ApiBase::PROP_NULLABLE => true
+ ),
+ 'texthidden' => 'boolean'
+ )
+ );
+
+ self::addTokenProperties( $props, $this->getTokenFunctions() );
+
+ return $props;
+ }
+
public function getDescription() {
return array(
'Get revision information',