dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Convert article delete to use OOUI"
[lhc/web/wiklou.git]
/
includes
/
api
/
ApiQueryAllDeletedRevisions.php
diff --git
a/includes/api/ApiQueryAllDeletedRevisions.php
b/includes/api/ApiQueryAllDeletedRevisions.php
index
a559683
..
b22bb1f
100644
(file)
--- a/
includes/api/ApiQueryAllDeletedRevisions.php
+++ b/
includes/api/ApiQueryAllDeletedRevisions.php
@@
-2,7
+2,7
@@
/**
* Created on Oct 3, 2014
*
/**
* Created on Oct 3, 2014
*
- * Copyright © 2014
Brad Jorsch "bjorsch@wikimedia.org"
+ * Copyright © 2014
Wikimedia Foundation and contributors
*
* Heavily based on ApiQueryDeletedrevs,
* Copyright © 2007 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
*
* Heavily based on ApiQueryDeletedrevs,
* Copyright © 2007 Roan Kattouw "<Firstname>.<Lastname>@gmail.com"
@@
-41,20
+41,23
@@
class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
* @return void
*/
protected function run( ApiPageSet $resultPageSet = null ) {
* @return void
*/
protected function run( ApiPageSet $resultPageSet = null ) {
- $user = $this->getUser();
// Before doing anything at all, let's check permissions
// Before doing anything at all, let's check permissions
- if ( !$user->isAllowed( 'deletedhistory' ) ) {
- $this->dieUsage(
- 'You don\'t have permission to view deleted revision information',
- 'permissiondenied'
- );
- }
+ $this->checkUserRightsAny( 'deletedhistory' );
+ $user = $this->getUser();
$db = $this->getDB();
$params = $this->extractRequestParams( false );
$result = $this->getResult();
$db = $this->getDB();
$params = $this->extractRequestParams( false );
$result = $this->getResult();
+ // If the user wants no namespaces, they get no pages.
+ if ( $params['namespace'] === [] ) {
+ if ( $resultPageSet === null ) {
+ $result->addValue( 'query', $this->getModuleName(), [] );
+ }
+ return;
+ }
+
// This module operates in two modes:
// 'user': List deleted revs by a certain user
// 'all': List all deleted revs in NS
// This module operates in two modes:
// 'user': List deleted revs by a certain user
// 'all': List all deleted revs in NS
@@
-67,16
+70,20
@@
class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
foreach ( [ 'from', 'to', 'prefix', 'excludeuser' ] as $param ) {
if ( !is_null( $params[$param] ) ) {
$p = $this->getModulePrefix();
foreach ( [ 'from', 'to', 'prefix', 'excludeuser' ] as $param ) {
if ( !is_null( $params[$param] ) ) {
$p = $this->getModulePrefix();
- $this->dieUsage( "The '{$p}{$param}' parameter cannot be used with '{$p}user'",
- 'badparams' );
+ $this->dieWithError(
+ [ 'apierror-invalidparammix-cannotusewith', $p.$param, "{$p}user" ],
+ 'invalidparammix'
+ );
}
}
} else {
foreach ( [ 'start', 'end' ] as $param ) {
if ( !is_null( $params[$param] ) ) {
$p = $this->getModulePrefix();
}
}
} else {
foreach ( [ 'start', 'end' ] as $param ) {
if ( !is_null( $params[$param] ) ) {
$p = $this->getModulePrefix();
- $this->dieUsage( "The '{$p}{$param}' parameter may only be used with '{$p}user'",
- 'badparams' );
+ $this->dieWithError(
+ [ 'apierror-invalidparammix-mustusewith', $p.$param, "{$p}user" ],
+ 'invalidparammix'
+ );
}
}
}
}
}
}
@@
-92,7
+99,7
@@
class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
$optimizeGenerateTitles = true;
} else {
$p = $this->getModulePrefix();
$optimizeGenerateTitles = true;
} else {
$p = $this->getModulePrefix();
- $this->
setWarning( "For better performance when generating titles, set {$p}dir=newer"
);
+ $this->
addWarning( [ 'apiwarn-alldeletedrevisions-performance', $p ], 'performance'
);
}
}
}
}
@@
-140,12
+147,7
@@
class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
$this->addFields( [ 'ar_text', 'ar_flags', 'old_text', 'old_flags' ] );
// This also means stricter restrictions
$this->addFields( [ 'ar_text', 'ar_flags', 'old_text', 'old_flags' ] );
// This also means stricter restrictions
- if ( !$user->isAllowedAny( 'undelete', 'deletedtext' ) ) {
- $this->dieUsage(
- 'You don\'t have permission to view deleted revision content',
- 'permissiondenied'
- );
- }
+ $this->checkUserRightsAny( [ 'deletedtext', 'undelete' ] );
}
$miser_ns = null;
}
$miser_ns = null;
@@
-153,10
+155,10
@@
class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
if ( $mode == 'all' ) {
if ( $params['namespace'] !== null ) {
$namespaces = $params['namespace'];
if ( $mode == 'all' ) {
if ( $params['namespace'] !== null ) {
$namespaces = $params['namespace'];
- $this->addWhereFld( 'ar_namespace', $namespaces );
} else {
$namespaces = MWNamespace::getValidNamespaces();
}
} else {
$namespaces = MWNamespace::getValidNamespaces();
}
+ $this->addWhereFld( 'ar_namespace', $namespaces );
// For from/to/prefix, we have to consider the potential
// transformations of the title in all specified namespaces.
// For from/to/prefix, we have to consider the potential
// transformations of the title in all specified namespaces.
@@
-228,7
+230,7
@@
class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
}
if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
}
if ( !is_null( $params['user'] ) || !is_null( $params['excludeuser'] ) ) {
- // Paranoia: avoid brute force searches (
bug 17
342)
+ // Paranoia: avoid brute force searches (
T19
342)
// (shouldn't be able to get here without 'deletedhistory', but
// check it again just in case)
if ( !$user->isAllowed( 'deletedhistory' ) ) {
// (shouldn't be able to get here without 'deletedhistory', but
// check it again just in case)
if ( !$user->isAllowed( 'deletedhistory' ) ) {
@@
-447,12
+449,12
@@
class ApiQueryAllDeletedRevisions extends ApiQueryRevisionsBase {
return [
'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50'
=> 'apihelp-query+alldeletedrevisions-example-user',
return [
'action=query&list=alldeletedrevisions&adruser=Example&adrlimit=50'
=> 'apihelp-query+alldeletedrevisions-example-user',
- 'action=query&list=alldeletedrevisions&adrdir=newer&adrlimit=50'
+ 'action=query&list=alldeletedrevisions&adrdir=newer&adr
namespace=0&adr
limit=50'
=> 'apihelp-query+alldeletedrevisions-example-ns-main',
];
}
public function getHelpUrls() {
=> 'apihelp-query+alldeletedrevisions-example-ns-main',
];
}
public function getHelpUrls() {
- return 'https://www.mediawiki.org/wiki/API:Alldeletedrevisions';
+ return 'https://www.mediawiki.org/wiki/
Special:MyLanguage/
API:Alldeletedrevisions';
}
}
}
}