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 "WANCacheReapUpdate: Handle special pages without exception"
[lhc/web/wiklou.git]
/
includes
/
api
/
ApiOptions.php
diff --git
a/includes/api/ApiOptions.php
b/includes/api/ApiOptions.php
index
8bfe447
..
5b0d86a
100644
(file)
--- a/
includes/api/ApiOptions.php
+++ b/
includes/api/ApiOptions.php
@@
-36,22
+36,26
@@
class ApiOptions extends ApiBase {
*/
public function execute() {
if ( $this->getUser()->isAnon() ) {
*/
public function execute() {
if ( $this->getUser()->isAnon() ) {
- $this->die
Usage( 'Anonymous users cannot change preferences', 'notloggedin' );
- } elseif ( !$this->getUser()->isAllowed( 'editmyoptions' ) ) {
-
$this->dieUsage( "You don't have permission to edit your options", 'permissiondenied'
);
+ $this->die
WithError(
+ [ 'apierror-mustbeloggedin', $this->msg( 'action-editmyoptions' ) ], 'notloggedin'
+ );
}
}
+ $this->checkUserRightsAny( 'editmyoptions' );
+
$params = $this->extractRequestParams();
$changed = false;
if ( isset( $params['optionvalue'] ) && !isset( $params['optionname'] ) ) {
$params = $this->extractRequestParams();
$changed = false;
if ( isset( $params['optionvalue'] ) && !isset( $params['optionname'] ) ) {
- $this->die
UsageMsg( [ '
missingparam', 'optionname' ] );
+ $this->die
WithError( [ 'apierror-
missingparam', 'optionname' ] );
}
// Load the user from the master to reduce CAS errors on double post (T95839)
$user = $this->getUser()->getInstanceForUpdate();
if ( !$user ) {
}
// Load the user from the master to reduce CAS errors on double post (T95839)
$user = $this->getUser()->getInstanceForUpdate();
if ( !$user ) {
- $this->dieUsage( 'Anonymous users cannot change preferences', 'notloggedin' );
+ $this->dieWithError(
+ [ 'apierror-mustbeloggedin', $this->msg( 'action-editmyoptions' ) ], 'notloggedin'
+ );
}
if ( $params['reset'] ) {
}
if ( $params['reset'] ) {
@@
-71,7
+75,7
@@
class ApiOptions extends ApiBase {
$changes[$params['optionname']] = $newValue;
}
if ( !$changed && !count( $changes ) ) {
$changes[$params['optionname']] = $newValue;
}
if ( !$changed && !count( $changes ) ) {
- $this->die
Usage( 'No changes were requested', '
nochanges' );
+ $this->die
WithError( 'apierror-
nochanges' );
}
$prefs = Preferences::getPreferences( $user, $this->getContext() );
}
$prefs = Preferences::getPreferences( $user, $this->getContext() );
@@
-98,26
+102,26
@@
class ApiOptions extends ApiBase {
case 'userjs':
// Allow non-default preferences prefixed with 'userjs-', to be set by user scripts
if ( strlen( $key ) > 255 ) {
case 'userjs':
// Allow non-default preferences prefixed with 'userjs-', to be set by user scripts
if ( strlen( $key ) > 255 ) {
- $validation =
'key too long (no more than 255 bytes allowed)'
;
+ $validation =
$this->msg( 'apiwarn-validationfailed-keytoolong', Message::numParam( 255 ) )
;
} elseif ( preg_match( '/[^a-zA-Z0-9_-]/', $key ) !== 0 ) {
} elseif ( preg_match( '/[^a-zA-Z0-9_-]/', $key ) !== 0 ) {
- $validation =
'invalid key (only a-z, A-Z, 0-9, _, - allowed)'
;
+ $validation =
$this->msg( 'apiwarn-validationfailed-badchars' )
;
} else {
$validation = true;
}
break;
case 'special':
} else {
$validation = true;
}
break;
case 'special':
- $validation =
'cannot be set by this module'
;
+ $validation =
$this->msg( 'apiwarn-validationfailed-cannotset' )
;
break;
case 'unused':
default:
break;
case 'unused':
default:
- $validation =
'not a valid preference'
;
+ $validation =
$this->msg( 'apiwarn-validationfailed-badpref' )
;
break;
}
if ( $validation === true ) {
$user->setOption( $key, $value );
$changed = true;
} else {
break;
}
if ( $validation === true ) {
$user->setOption( $key, $value );
$changed = true;
} else {
- $this->
setWarning( "Validation error for '$key': $validation"
);
+ $this->
addWarning( [ 'apiwarn-validationfailed', wfEscapeWikitext( $key ), $validation ]
);
}
}
}
}
@@
-165,7
+169,7
@@
class ApiOptions extends ApiBase {
}
public function getHelpUrls() {
}
public function getHelpUrls() {
- return 'https://www.mediawiki.org/wiki/API:Options';
+ return 'https://www.mediawiki.org/wiki/
Special:MyLanguage/
API:Options';
}
protected function getExamplesMessages() {
}
protected function getExamplesMessages() {