AuthManager: Commit transaction after auto-creating a user
authorBrad Jorsch <bjorsch@wikimedia.org>
Tue, 12 Jul 2016 17:35:10 +0000 (13:35 -0400)
committerBrad Jorsch <bjorsch@wikimedia.org>
Tue, 12 Jul 2016 17:35:10 +0000 (13:35 -0400)
As things stand now, DBO_TRX or DBO_DEFAULT will cause a transaction to
be started, and then anything in the entire request failing will
probably cause the newly-added user row to be lost. But updates to
external databases (e.g. CentralAuth) likely won't be since those DB
connections were probably shut down after the update was completed.

So let's explicitly commit changes af the end of auto-creation so that
problems with the request itself don't undo it.

Bug: T119736
Change-Id: I6c13c8feb86d8b9a01df894733c38445d048fea0

includes/auth/AuthManager.php

index 6db5f2c..82eeff0 100644 (file)
@@ -1695,6 +1695,10 @@ class AuthManager implements LoggerAwareInterface {
                        $logid = $logEntry->insert();
                }
 
+               // Commit database changes, so even if something else later blows up
+               // the newly-created user doesn't get lost.
+               wfGetLBFactory()->commitMasterChanges( __METHOD__ );
+
                if ( $login ) {
                        $this->setSessionDataForUser( $user );
                }