Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/88995
Change subject: API: Handle "special" options in action=options
......................................................................
API: Handle "special" options in action=options
There are certain preferences, such as realname and emailaddress, that
are handled specially in Special:Preferences and are not accessible by
User::getOptions or User::setOptions. But action=options was allowing
a 'dummy' version to be set in User::setOptions.
Change-Id: I4c1b3d8e1eae9520228d7b6da9c41ada80f7c387
---
M includes/Preferences.php
M includes/User.php
M includes/api/ApiOptions.php
3 files changed, 22 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/95/88995/1
diff --git a/includes/Preferences.php b/includes/Preferences.php
index c9caf4f..87118d6 100644
--- a/includes/Preferences.php
+++ b/includes/Preferences.php
@@ -63,6 +63,13 @@
);
/**
+ * @return array
+ */
+ static function getSaveBlacklist() {
+ return self::$saveBlacklist;
+ }
+
+ /**
* @throws MWException
* @param $user User
* @param $context IContextSource
diff --git a/includes/User.php b/includes/User.php
index 12912e1..d6e0a51 100644
--- a/includes/User.php
+++ b/includes/User.php
@@ -2443,6 +2443,8 @@
* - 'registered-checkmatrix' - as above, using the 'checkmatrix' type.
* - 'userjs' - preferences with names starting with 'userjs-',
intended to
* be used by user scripts.
+ * - 'special' - "preferences" that are not accessible via
User::getOptions
+ * or User::setOptions.
* - 'unused' - preferences about which MediaWiki doesn't know anything.
* These are usually legacy options, removed in newer
versions.
*
@@ -2459,6 +2461,7 @@
'registered-multiselect',
'registered-checkmatrix',
'userjs',
+ 'special',
'unused'
);
}
@@ -2482,6 +2485,13 @@
$prefs = Preferences::getPreferences( $this, $context );
$mapping = array();
+
+ // Pull out the "special" options, so they don't get converted
as
+ // multiselect or checkmatrix.
+ $specialOptions = array_fill_keys(
Preferences::getSaveBlacklist(), true );
+ foreach ( $specialOptions as $name => $value ) {
+ unset( $prefs[$name] );
+ }
// Multiselect and checkmatrix options are stored in the
database with
// one key per option, each having a boolean value. Extract
those keys.
@@ -2525,6 +2535,8 @@
$mapping[$key] = 'registered-multiselect';
} elseif ( isset( $checkmatrixOptions[$key] ) ) {
$mapping[$key] = 'registered-checkmatrix';
+ } elseif ( isset( $specialOptions[$key] ) ) {
+ $mapping[$key] = 'special';
} elseif ( substr( $key, 0, 7 ) === 'userjs-' ) {
$mapping[$key] = 'userjs';
} else {
diff --git a/includes/api/ApiOptions.php b/includes/api/ApiOptions.php
index b5aec77..c9d6378 100644
--- a/includes/api/ApiOptions.php
+++ b/includes/api/ApiOptions.php
@@ -99,6 +99,9 @@
$validation = true;
}
break;
+ case 'special':
+ $validation = "cannot be set by this
module";
+ break;
case 'unused':
default:
$validation = "not a valid preference";
--
To view, visit https://gerrit.wikimedia.org/r/88995
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4c1b3d8e1eae9520228d7b6da9c41ada80f7c387
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits