Preferences.php: avoid "Undefined index" if key 'realname' don't exist in $formdata
[lhc/web/wiklou.git] / includes / Preferences.php
index 04e9114..b47115b 100644 (file)
@@ -62,6 +62,13 @@ class Preferences {
                'emailaddress',
        );
 
+       /**
+        * @return array
+        */
+       static function getSaveBlacklist() {
+               return self::$saveBlacklist;
+       }
+
        /**
         * @throws MWException
         * @param $user User
@@ -761,14 +768,6 @@ class Preferences {
                        'label-message' => 'tog-showhiddencats'
                );
 
-               if ( $wgAllowUserCssPrefs ) {
-                       $defaultPreferences['justify'] = array(
-                               'type' => 'toggle',
-                               'section' => 'rendering/advancedrendering',
-                               'label-message' => 'tog-justify',
-                       );
-               }
-
                $defaultPreferences['numberheadings'] = array(
                        'type' => 'toggle',
                        'section' => 'rendering/advancedrendering',
@@ -1031,15 +1030,7 @@ class Preferences {
         * @param $defaultPreferences Array
         */
        static function searchPreferences( $user, IContextSource $context, &$defaultPreferences ) {
-               global $wgContLang, $wgVectorUseSimpleSearch;
-
-               if ( $wgVectorUseSimpleSearch ) {
-                       $defaultPreferences['vector-simplesearch'] = array(
-                               'type' => 'toggle',
-                               'label-message' => 'vector-simplesearch-preference',
-                               'section' => 'searchoptions/displaysearchoptions',
-                       );
-               }
+               global $wgContLang;
 
                $defaultPreferences['searcheverything'] = array(
                        'type' => 'toggle',
@@ -1405,10 +1396,9 @@ class Preferences {
         *
         * @param $formData
         * @param $form PreferencesForm
-        * @param $entryPoint string
         * @return bool|Status|string
         */
-       static function tryFormSubmit( $formData, $form, $entryPoint = 'internal' ) {
+       static function tryFormSubmit( $formData, $form ) {
                global $wgHiddenPrefs, $wgAuth;
 
                $user = $form->getModifiedUser();
@@ -1428,7 +1418,7 @@ class Preferences {
 
                // Fortunately, the realname field is MUCH simpler
                // (not really "private", but still shouldn't be edited without permission)
-               if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) ) {
+               if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) && array_key_exists( 'realname', $formData ) ) {
                        $realName = $formData['realname'];
                        $user->setRealName( $realName );
                }
@@ -1454,6 +1444,7 @@ class Preferences {
                                $user->setOption( $key, $value );
                        }
 
+                       wfRunHooks( 'PreferencesFormPreSave', array( $formData, $form, $user, &$result ) );
                        $user->saveSettings();
                }
 
@@ -1468,7 +1459,7 @@ class Preferences {
         * @return Status
         */
        public static function tryUISubmit( $formData, $form ) {
-               $res = self::tryFormSubmit( $formData, $form, 'ui' );
+               $res = self::tryFormSubmit( $formData, $form );
 
                if ( $res ) {
                        $urlOptions = array( 'success' => 1 );