summaryrefslogtreecommitdiff
path: root/includes/api/ApiQueryDeletedrevs.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiQueryDeletedrevs.php')
-rw-r--r--includes/api/ApiQueryDeletedrevs.php158
1 files changed, 69 insertions, 89 deletions
diff --git a/includes/api/ApiQueryDeletedrevs.php b/includes/api/ApiQueryDeletedrevs.php
index 9042696b..72a331f1 100644
--- a/includes/api/ApiQueryDeletedrevs.php
+++ b/includes/api/ApiQueryDeletedrevs.php
@@ -28,6 +28,7 @@
* Query module to enumerate all deleted revisions.
*
* @ingroup API
+ * @deprecated since 1.25
*/
class ApiQueryDeletedrevs extends ApiQueryBase {
@@ -45,6 +46,12 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
);
}
+ $this->setWarning(
+ 'list=deletedrevs has been deprecated. Please use prop=deletedrevisions or ' .
+ 'list=alldeletedrevisions instead.'
+ );
+ $this->logFeatureUsage( 'action=query&list=deletedrevs' );
+
$db = $this->getDB();
$params = $this->extractRequestParams( false );
$prop = array_flip( $params['prop'] );
@@ -68,8 +75,9 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
);
}
- // If we're in JSON callback mode, no tokens can be obtained
- if ( !is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) {
+ // If we're in a mode that breaks the same-origin policy, no tokens can
+ // be obtained
+ if ( $this->lacksSameOriginSecurity() ) {
$fld_token = false;
}
@@ -169,7 +177,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
if ( $limit == 'max' ) {
$limit = $this->getMain()->canApiHighLimits() ? $botMax : $userMax;
- $this->getResult()->setParsedLimit( $this->getModuleName(), $limit );
+ $this->getResult()->addParsedLimit( $this->getModuleName(), $limit );
}
$this->validateLimit( 'limit', $limit, 1, $userMax, $botMax );
@@ -312,7 +320,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
}
if ( $fld_user || $fld_userid ) {
if ( $row->ar_deleted & Revision::DELETED_USER ) {
- $rev['userhidden'] = '';
+ $rev['userhidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_USER, $user ) ) {
@@ -327,7 +335,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
if ( $fld_comment || $fld_parsedcomment ) {
if ( $row->ar_deleted & Revision::DELETED_COMMENT ) {
- $rev['commenthidden'] = '';
+ $rev['commenthidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_COMMENT, $user ) ) {
@@ -341,15 +349,15 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
}
}
- if ( $fld_minor && $row->ar_minor_edit == 1 ) {
- $rev['minor'] = '';
+ if ( $fld_minor ) {
+ $rev['minor'] = $row->ar_minor_edit == 1;
}
if ( $fld_len ) {
$rev['len'] = $row->ar_len;
}
if ( $fld_sha1 ) {
if ( $row->ar_deleted & Revision::DELETED_TEXT ) {
- $rev['sha1hidden'] = '';
+ $rev['sha1hidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_TEXT, $user ) ) {
@@ -362,15 +370,15 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
}
if ( $fld_content ) {
if ( $row->ar_deleted & Revision::DELETED_TEXT ) {
- $rev['texthidden'] = '';
+ $rev['texthidden'] = true;
$anyHidden = true;
}
if ( Revision::userCanBitfield( $row->ar_deleted, Revision::DELETED_TEXT, $user ) ) {
if ( isset( $row->ar_text ) && !$row->ar_text_id ) {
// Pre-1.5 ar_text row (if condition from Revision::newFromArchiveRow)
- ApiResult::setContent( $rev, Revision::getRevisionText( $row, 'ar_' ) );
+ ApiResult::setContentValue( $rev, 'text', Revision::getRevisionText( $row, 'ar_' ) );
} else {
- ApiResult::setContent( $rev, Revision::getRevisionText( $row ) );
+ ApiResult::setContentValue( $rev, 'text', Revision::getRevisionText( $row ) );
}
}
}
@@ -378,7 +386,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
if ( $fld_tags ) {
if ( $row->ts_tags ) {
$tags = explode( ',', $row->ts_tags );
- $this->getResult()->setIndexedTagName( $tags, 'tag' );
+ ApiResult::setIndexedTagName( $tags, 'tag' );
$rev['tags'] = $tags;
} else {
$rev['tags'] = array();
@@ -386,14 +394,14 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
}
if ( $anyHidden && ( $row->ar_deleted & Revision::DELETED_RESTRICTED ) ) {
- $rev['suppressed'] = '';
+ $rev['suppressed'] = true;
}
if ( !isset( $pageMap[$row->ar_namespace][$row->ar_title] ) ) {
$pageID = $newPageID++;
$pageMap[$row->ar_namespace][$row->ar_title] = $pageID;
$a['revisions'] = array( $rev );
- $result->setIndexedTagName( $a['revisions'], 'rev' );
+ ApiResult::setIndexedTagName( $a['revisions'], 'rev' );
$title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
ApiQueryBase::addTitleInfo( $a, $title );
if ( $fld_token ) {
@@ -417,46 +425,56 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
break;
}
}
- $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'page' );
+ $result->addIndexedTagName( array( 'query', $this->getModuleName() ), 'page' );
+ }
+
+ public function isDeprecated() {
+ return true;
}
public function getAllowedParams() {
return array(
'start' => array(
- ApiBase::PARAM_TYPE => 'timestamp'
+ ApiBase::PARAM_TYPE => 'timestamp',
+ ApiBase::PARAM_HELP_MSG_INFO => array( array( 'modes', 1, 2 ) ),
),
'end' => array(
ApiBase::PARAM_TYPE => 'timestamp',
+ ApiBase::PARAM_HELP_MSG_INFO => array( array( 'modes', 1, 2 ) ),
),
'dir' => array(
ApiBase::PARAM_TYPE => array(
'newer',
'older'
),
- ApiBase::PARAM_DFLT => 'older'
+ ApiBase::PARAM_DFLT => 'older',
+ ApiBase::PARAM_HELP_MSG => 'api-help-param-direction',
+ ApiBase::PARAM_HELP_MSG_INFO => array( array( 'modes', 1, 3 ) ),
),
- 'from' => null,
- 'to' => null,
- 'prefix' => null,
- 'continue' => null,
- 'unique' => false,
- 'tag' => null,
- 'user' => array(
- ApiBase::PARAM_TYPE => 'user'
+ 'from' => array(
+ ApiBase::PARAM_HELP_MSG_INFO => array( array( 'modes', 3 ) ),
),
- 'excludeuser' => array(
- ApiBase::PARAM_TYPE => 'user'
+ 'to' => array(
+ ApiBase::PARAM_HELP_MSG_INFO => array( array( 'modes', 3 ) ),
+ ),
+ 'prefix' => array(
+ ApiBase::PARAM_HELP_MSG_INFO => array( array( 'modes', 3 ) ),
+ ),
+ 'unique' => array(
+ ApiBase::PARAM_DFLT => false,
+ ApiBase::PARAM_HELP_MSG_INFO => array( array( 'modes', 3 ) ),
),
'namespace' => array(
ApiBase::PARAM_TYPE => 'namespace',
ApiBase::PARAM_DFLT => NS_MAIN,
+ ApiBase::PARAM_HELP_MSG_INFO => array( array( 'modes', 3 ) ),
),
- 'limit' => array(
- ApiBase::PARAM_DFLT => 10,
- ApiBase::PARAM_TYPE => 'limit',
- ApiBase::PARAM_MIN => 1,
- ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
- ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
+ 'tag' => null,
+ 'user' => array(
+ ApiBase::PARAM_TYPE => 'user'
+ ),
+ 'excludeuser' => array(
+ ApiBase::PARAM_TYPE => 'user'
),
'prop' => array(
ApiBase::PARAM_DFLT => 'user|comment',
@@ -476,68 +494,30 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
),
ApiBase::PARAM_ISMULTI => true
),
- );
- }
-
- public function getParamDescription() {
- return 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, 3)' ),
- 'from' => 'Start listing at this title (3)',
- 'to' => 'Stop listing at this title (3)',
- 'prefix' => 'Search for all page titles that begin with this value (3)',
- 'limit' => 'The maximum amount of revisions to list',
- 'prop' => array(
- 'Which properties to get',
- ' revid - Adds the revision ID of the deleted revision',
- ' parentid - Adds the revision ID of the previous revision to the page',
- ' user - Adds the user who made the revision',
- ' userid - Adds the user ID whom made the revision',
- ' comment - Adds the comment of the revision',
- ' parsedcomment - Adds the parsed comment of the revision',
- ' minor - Tags if the revision is minor',
- ' len - Adds the length (bytes) of the revision',
- ' sha1 - Adds the SHA-1 (base 16) of the revision',
- ' content - Adds the content of the revision',
- ' token - DEPRECATED! Gives the edit token',
- ' tags - Tags for the revision',
+ 'limit' => array(
+ ApiBase::PARAM_DFLT => 10,
+ ApiBase::PARAM_TYPE => 'limit',
+ ApiBase::PARAM_MIN => 1,
+ ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1,
+ ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2
+ ),
+ 'continue' => array(
+ ApiBase::PARAM_HELP_MSG => 'api-help-param-continue',
),
- 'namespace' => 'Only list pages in this namespace (3)',
- 'user' => 'Only list revisions by this user',
- 'excludeuser' => 'Don\'t list revisions by this user',
- 'continue' => 'When more results are available, use this to continue',
- 'unique' => 'List only one revision for each page (3)',
- 'tag' => 'Only list revisions tagged with this tag',
- );
- }
-
- public function getDescription() {
- $p = $this->getModulePrefix();
-
- return array(
- 'List deleted revisions.',
- 'Operates in three modes:',
- ' 1) List deleted revisions for the given title(s), sorted by timestamp.',
- ' 2) List deleted contributions for the given user, sorted by timestamp (no titles specified).',
- ' 3) List all deleted revisions in the given namespace, sorted by title and timestamp',
- " (no titles specified, {$p}user not set).",
- 'Certain parameters only apply to some modes and are ignored in others.',
- 'For instance, a parameter marked (1) only applies to mode 1 and is ignored in modes 2 and 3.',
);
}
- public function getExamples() {
+ protected function getExamplesMessages() {
return array(
- 'api.php?action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&' .
+ 'action=query&list=deletedrevs&titles=Main%20Page|Talk:Main%20Page&' .
'drprop=user|comment|content'
- => 'List the last deleted revisions of Main Page and Talk:Main Page, with content (mode 1)',
- 'api.php?action=query&list=deletedrevs&druser=Bob&drlimit=50'
- => 'List the last 50 deleted contributions by Bob (mode 2)',
- 'api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50'
- => 'List the first 50 deleted revisions in the main namespace (mode 3)',
- 'api.php?action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique='
- => 'List the first 50 deleted pages in the Talk namespace (mode 3):',
+ => 'apihelp-query+deletedrevs-example-mode1',
+ 'action=query&list=deletedrevs&druser=Bob&drlimit=50'
+ => 'apihelp-query+deletedrevs-example-mode2',
+ 'action=query&list=deletedrevs&drdir=newer&drlimit=50'
+ => 'apihelp-query+deletedrevs-example-mode3-main',
+ 'action=query&list=deletedrevs&drdir=newer&drlimit=50&drnamespace=1&drunique='
+ => 'apihelp-query+deletedrevs-example-mode3-talk',
);
}