Merge "Revert "AuthManager: Commit transaction after auto-creating a user""
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 18 Aug 2016 20:16:47 +0000 (20:16 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 18 Aug 2016 20:16:47 +0000 (20:16 +0000)
1  2 
includes/auth/AuthManager.php

@@@ -1688,13 -1688,9 +1688,9 @@@ class AuthManager implements LoggerAwar
                        $logEntry->setParameters( [
                                '4::userid' => $user->getId(),
                        ] );
-                       $logid = $logEntry->insert();
+                       $logEntry->insert();
                }
  
-               // Commit database changes, so even if something else later blows up
-               // the newly-created user doesn't get lost.
-               wfGetLBFactory()->commitMasterChanges( __METHOD__ );
                $trxProfiler->setSilenced( false );
  
                if ( $login ) {
  
                // Query them and merge results
                $reqs = [];
 -              $allPrimaryRequired = null;
                foreach ( $providers as $provider ) {
                        $isPrimary = $provider instanceof PrimaryAuthenticationProvider;
 -                      $thisRequired = [];
                        foreach ( $provider->getAuthenticationRequests( $providerAction, $options ) as $req ) {
                                $id = $req->getUniqueId();
  
 -                              // If it's from a Primary, mark it as "primary-required" but
 -                              // track it for later.
 +                              // If a required request if from a Primary, mark it as "primary-required" instead
                                if ( $isPrimary ) {
                                        if ( $req->required ) {
 -                                              $thisRequired[$id] = true;
                                                $req->required = AuthenticationRequest::PRIMARY_REQUIRED;
                                        }
                                }
  
 -                              if ( !isset( $reqs[$id] ) || $req->required === AuthenticationRequest::REQUIRED ) {
 +                              if (
 +                                      !isset( $reqs[$id] )
 +                                      || $req->required === AuthenticationRequest::REQUIRED
 +                                      || $reqs[$id] === AuthenticationRequest::OPTIONAL
 +                              ) {
                                        $reqs[$id] = $req;
                                }
                        }
 -
 -                      // Track which requests are required by all primaries
 -                      if ( $isPrimary ) {
 -                              $allPrimaryRequired = $allPrimaryRequired === null
 -                                      ? $thisRequired
 -                                      : array_intersect_key( $allPrimaryRequired, $thisRequired );
 -                      }
 -              }
 -              // Any requests that were required by all primaries are required.
 -              foreach ( (array)$allPrimaryRequired as $id => $dummy ) {
 -                      $reqs[$id]->required = AuthenticationRequest::REQUIRED;
                }
  
                // AuthManager has its own req for some actions