* - '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.
*
'registered-multiselect',
'registered-checkmatrix',
'userjs',
+ 'special',
'unused'
);
}
$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.
$multiselectOptions = array();
$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 {
return;
}
- $defaultOptions = self::getDefaultOptions();
-
$userId = $this->getId();
$insert_rows = array();
- $changedOptions = array_diff_assoc( $saveOptions, $defaultOptions );
- foreach ( $changedOptions as $key => $value ) {
- if ( $value === false || is_null( $value ) ) {
- continue;
+ foreach ( $saveOptions as $key => $value ) {
+ // Don't bother storing default values
+ $defaultOption = self::getDefaultOption( $key );
+ if ( ( is_null( $defaultOption ) &&
+ !( $value === false || is_null( $value ) ) ) ||
+ $value != $defaultOption ) {
+ $insert_rows[] = array(
+ 'up_user' => $userId,
+ 'up_property' => $key,
+ 'up_value' => $value,
+ );
}
- $insert_rows[] = array(
- 'up_user' => $userId,
- 'up_property' => $key,
- 'up_value' => $value,
- );
}
$dbw = wfGetDB( DB_MASTER );