Preferences.php: avoid "Undefined index" if key 'realname' don't exist in $formdata
[lhc/web/wiklou.git] / includes / Preferences.php
index ba1aae8..b47115b 100644 (file)
@@ -1030,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',
@@ -1404,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();
@@ -1427,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 );
                }
@@ -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 );