When saving preferences, check hook and authentication plugin, and actually save...
authorRotem Liss <rotem@users.mediawiki.org>
Fri, 12 Oct 2007 10:27:57 +0000 (10:27 +0000)
committerRotem Liss <rotem@users.mediawiki.org>
Fri, 12 Oct 2007 10:27:57 +0000 (10:27 +0000)
includes/SpecialPreferences.php

index fb8c01a..33a31ee 100644 (file)
@@ -299,20 +299,6 @@ class PreferencesForm {
                foreach ( $this->mToggles as $tname => $tvalue ) {
                        $wgUser->setOption( $tname, $tvalue );
                }
-               if (!$wgAuth->updateExternalDB($wgUser)) {
-                       $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
-                       return;
-               }
-
-               $msg = '';
-               if ( !wfRunHooks( "SavePreferences", array( $this, $wgUser, &$msg ) ) ) {
-                       print "(($msg))";
-                       $this->mainPrefsForm( 'error', $msg ); 
-                       return;
-               }
-
-               $wgUser->setCookies();
-               $wgUser->saveSettings();
 
                $error = false;
                if( $wgEnableEmail ) {
@@ -323,7 +309,6 @@ class PreferencesForm {
                                if( $wgUser->isValidEmailAddr( $newadr ) ) {
                                        $wgUser->mEmail = $newadr; # new behaviour: set this new emailaddr from login-page into user database record
                                        $wgUser->mEmailAuthenticated = null; # but flag as "dirty" = unauthenticated
-                                       $wgUser->saveSettings();
                                        if ($wgEmailAuthentication) {
                                                # Mail a temporary password to the dirty address.
                                                # User can come back through the confirmation URL to re-enable email.
@@ -343,14 +328,27 @@ class PreferencesForm {
                                        return;
                                }
                                $wgUser->setEmail( $this->mUserEmail );
-                               $wgUser->setCookies();
-                               $wgUser->saveSettings();
                        }
                        if( $oldadr != $newadr ) {
                                wfRunHooks( "PrefsEmailAudit", array( $wgUser, $oldadr, $newadr ) );
                        }
                }
 
+               if (!$wgAuth->updateExternalDB($wgUser)) {
+                       $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) );
+                       return;
+               }
+
+               $msg = '';
+               if ( !wfRunHooks( "SavePreferences", array( $this, $wgUser, &$msg ) ) ) {
+                       print "(($msg))";
+                       $this->mainPrefsForm( 'error', $msg );
+                       return;
+               }
+
+               $wgUser->setCookies();
+               $wgUser->saveSettings();
+
                if( $needRedirect && $error === false ) {
                        $title =& SpecialPage::getTitleFor( "Preferences" );
                        $wgOut->redirect($title->getFullURL('success'));