From f582a7d313ed7abdad2054bbc164fa8a3150eeae Mon Sep 17 00:00:00 2001 From: Rotem Liss Date: Fri, 12 Oct 2007 10:27:57 +0000 Subject: [PATCH] When saving preferences, check hook and authentication plugin, and actually save the preferences, *after* the e-mail setting (the hook and authentication plugin should also check/update this). --- includes/SpecialPreferences.php | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/includes/SpecialPreferences.php b/includes/SpecialPreferences.php index fb8c01a1cc..33a31ee6ed 100644 --- a/includes/SpecialPreferences.php +++ b/includes/SpecialPreferences.php @@ -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')); -- 2.20.1