diff options
author | Brian Evans <grknight@gentoo.org> | 2019-01-11 13:17:12 -0500 |
---|---|---|
committer | Brian Evans <grknight@gentoo.org> | 2019-01-11 13:17:12 -0500 |
commit | 4e0791cdcdcc62d931736ef5a19aa5b2461343d9 (patch) | |
tree | 3fea50729109554c015c25b8246590aa57cb1736 | |
parent | EditAccount: ShoutWiki -> Gentoo Wiki (diff) | |
download | extensions-4e0791cdcdcc62d931736ef5a19aa5b2461343d9.tar.gz extensions-4e0791cdcdcc62d931736ef5a19aa5b2461343d9.tar.bz2 extensions-4e0791cdcdcc62d931736ef5a19aa5b2461343d9.zip |
EditAccount: Fix database timing issuesv1.30.1.2
Signed-off-by: Brian Evans <grknight@gentoo.org>
-rw-r--r-- | EditAccount/SpecialEditAccount_body.php | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/EditAccount/SpecialEditAccount_body.php b/EditAccount/SpecialEditAccount_body.php index 4f2eec96..b44b22c7 100644 --- a/EditAccount/SpecialEditAccount_body.php +++ b/EditAccount/SpecialEditAccount_body.php @@ -389,13 +389,14 @@ class EditAccount extends SpecialPage { * @return bool True on success, false on failure */ function closeAccount( $changeReason = '' ) { + $updUser = $this->mUser->getInstanceForUpdate(); // Set flag for Special:Contributions // NOTE: requires FlagClosedAccounts.php to be included separately if ( defined( 'CLOSED_ACCOUNT_FLAG' ) ) { - $this->mUser->setRealName( CLOSED_ACCOUNT_FLAG ); + $updUser->setRealName( CLOSED_ACCOUNT_FLAG ); } else { // magic value not found, so let's at least blank it - $this->mUser->setRealName( '' ); + $updUser->setRealName( '' ); } // remove user's avatar @@ -417,48 +418,43 @@ class EditAccount extends SpecialPage { } // Remove e-mail address and password - $this->mUser->setEmail( '' ); + $updUser->setEmail( '' ); $newPass = $this->generateRandomScrambledPassword(); - $this->mUser->setPassword( $newPass ); + $updUser->setPassword( $newPass ); // Save the new settings - $this->mUser->saveSettings(); - - $id = $this->mUser->getId(); - - // Reload user - $this->mUser = User::newFromId( $id ); + $updUser->saveSettings(); - if ( $this->mUser->getEmail() == '' ) { + if ( $updUser->getEmail() == '' ) { // ShoutWiki patch begin $this->setDisabled(); // ShoutWiki patch end // Mark as disabled in a more real way, that doesn't depend on the real_name text - $this->mUser->setOption( 'disabled', 1 ); - $this->mUser->setOption( 'disabled_date', wfTimestamp( TS_DB ) ); + $updUser->setOption( 'disabled', 1 ); + $updUser->setOption( 'disabled_date', wfTimestamp( TS_DB ) ); // BugId:18085 - setting a new token causes the user to be logged out. - $this->mUser->setToken( md5( microtime() . mt_rand( 0, 0x7fffffff ) ) ); + $updUser->setToken( md5( microtime() . mt_rand( 0, 0x7fffffff ) ) ); // BugID:95369 This forces saveSettings() to commit the transaction // FIXME: this is a total hack, we should add a commit=true flag to saveSettings $this->getRequest()->setVal( 'action', 'ajax' ); // Need to save these additional changes - $this->mUser->saveSettings(); + $updUser->saveSettings(); // Log what was done $logEntry = new ManualLogEntry( 'editaccnt', 'closeaccnt' ); $logEntry->setPerformer( $this->getUser() ); - $logEntry->setTarget( $this->mUser->getUserPage() ); + $logEntry->setTarget( $updUser->getUserPage() ); $logEntry->setComment( $changeReason ); // JP 13 April 2013: not sure if this is the correct one, CHECKME $logId = $logEntry->insert(); // All clear! - $this->mStatusMsg = $this->msg( 'editaccount-success-close', $this->mUser->mName )->text(); + $this->mStatusMsg = $this->msg( 'editaccount-success-close', $updUser->mName )->text(); return true; } else { // There were errors...inform the user about those - $this->mStatusMsg = $this->msg( 'editaccount-error-close', $this->mUser->mName )->text(); + $this->mStatusMsg = $this->msg( 'editaccount-error-close', $updUser->mName )->text(); return false; } } @@ -469,10 +465,11 @@ class EditAccount extends SpecialPage { * @return bool Always true */ function clearUnsubscribe() { - $this->mUser->setOption( 'unsubscribed', null ); - $this->mUser->saveSettings(); + $updUser = $this->mUser->getInstanceForUpdate(); + $updUser->setOption( 'unsubscribed', null ); + $updUser->saveSettings(); - $this->mStatusMsg = $this->msg( 'editaccount-success-unsub', $this->mUser->mName )->text(); + $this->mStatusMsg = $this->msg( 'editaccount-success-unsub', $updUser->mName )->text(); return true; } @@ -483,9 +480,10 @@ class EditAccount extends SpecialPage { * @return bool Always true */ function clearDisable() { - $this->mUser->setOption( 'disabled', null ); - $this->mUser->setOption( 'disabled_date', null ); - $this->mUser->saveSettings(); + $updUser = $this->mUser->getInstanceForUpdate(); + $updUser->setOption( 'disabled', null ); + $updUser->setOption( 'disabled_date', null ); + $updUser->saveSettings(); // ShoutWiki patch begin // We also need to clear GlobalPreferences data; otherwise it's possible @@ -501,7 +499,7 @@ class EditAccount extends SpecialPage { array( 'gp_property' => 'disabled', 'gp_value' => 1, - 'gp_user' => $this->mUser->getId() + 'gp_user' => $updUser->getId() ), __METHOD__ ); @@ -509,7 +507,7 @@ class EditAccount extends SpecialPage { 'global_preferences', array( 'gp_property' => 'disabled_date', - 'gp_user' => $this->mUser->getId() + 'gp_user' => $updUser->getId() ), __METHOD__ ); @@ -517,7 +515,7 @@ class EditAccount extends SpecialPage { } // ShoutWiki patch end - $this->mStatusMsg = $this->msg( 'editaccount-success-disable', $this->mUser->mName )->text(); + $this->mStatusMsg = $this->msg( 'editaccount-success-disable', $updUser->mName )->text(); return true; } @@ -549,8 +547,7 @@ class EditAccount extends SpecialPage { // always satisfy the digit/letter but not always. // This suffix shouldn't reduce the entropy of the intentionally // scrambled password. - $REQUIRED_CHARS = 'A1a'; - return ( self::generateToken() . $REQUIRED_CHARS ); + return PasswordFactory::generateRandomPasswordString(24); } /** |