unset( $formData[$b] );
}
+ # If users have saved a value for a preference which has subsequently been disabled
+ # via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
+ # is subsequently re-enabled
+ # TODO: maintenance script to actually delete these
+ foreach( $wgHiddenPrefs as $pref ){
+ # If the user has not set a non-default value here, the default will be returned
+ # and subsequently discarded
+ $formData[$pref] = $wgUser->getOption( $pref, null, true );
+ }
+
// Keeps old preferences from interfering due to back-compat
// code, etc.
$wgUser->resetOptions();
*
* @param $oname String The option to check
* @param $defaultOverride String A default value returned if the option does not exist
+ * @bool $ignoreHidden = whether to ignore the effects of $wgHiddenPrefs
* @return String User's current value for the option
* @see getBoolOption()
* @see getIntOption()
*/
- function getOption( $oname, $defaultOverride = null ) {
+ function getOption( $oname, $defaultOverride = null, $ignoreHidden = false ) {
+ global $wgHiddenPrefs;
$this->loadOptions();
if ( is_null( $this->mOptions ) ) {
$this->mOptions = User::getDefaultOptions();
}
+ # We want 'disabled' preferences to always behave as the default value for
+ # users, even if they have set the option explicitly in their settings (ie they
+ # set it, and then it was disabled removing their ability to change it). But
+ # we don't want to erase the preferences in the database in case the preference
+ # is re-enabled again. So don't touch $mOptions, just override the returned value
+ if( in_array( $oname, $wgHiddenPrefs ) && !$ignoreHidden ){
+ return self::getDefaultOption( $oname );
+ }
+
if ( array_key_exists( $oname, $this->mOptions ) ) {
return $this->mOptions[$oname];
} else {
* @return array
*/
public function getOptions() {
+ global $wgHiddenPrefs;
$this->loadOptions();
- return $this->mOptions;
+ $options = $this->mOptions;
+
+ # We want 'disabled' preferences to always behave as the default value for
+ # users, even if they have set the option explicitly in their settings (ie they
+ # set it, and then it was disabled removing their ability to change it). But
+ # we don't want to erase the preferences in the database in case the preference
+ # is re-enabled again. So don't touch $mOptions, just override the returned value
+ foreach( $wgHiddenPrefs as $pref ){
+ $default = self::getDefaultOption( $pref );
+ if( $default !== null ){
+ $options[$pref] = $default;
+ }
+ }
+
+ return $options;
}
/**