From: Aaron Schulz Date: Mon, 15 Aug 2016 14:14:57 +0000 (-0700) Subject: Make autoCreateUser() transaction profiler suppression limited in scope X-Git-Tag: 1.31.0-rc.0~6054^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=0d8c851d795f10f766e6d16ee137b4e94717e097;p=lhc%2Fweb%2Fwiklou.git Make autoCreateUser() transaction profiler suppression limited in scope Change-Id: If7b2330aa8cdf49ae25e5c0af5cb3ffc3f40b257 --- diff --git a/includes/auth/AuthManager.php b/includes/auth/AuthManager.php index eab50681cc..50e370e9e6 100644 --- a/includes/auth/AuthManager.php +++ b/includes/auth/AuthManager.php @@ -1605,9 +1605,6 @@ class AuthManager implements LoggerAwareInterface { } } - // Ignore warnings about master connections/writes...hard to avoid here - \Profiler::instance()->getTransactionProfiler()->resetExpectations(); - $backoffKey = wfMemcKey( 'AuthManager', 'autocreate-failed', md5( $username ) ); if ( $cache->get( $backoffKey ) ) { $this->logger->debug( __METHOD__ . ': {username} denied by prior creation attempt failures', [ @@ -1625,6 +1622,9 @@ class AuthManager implements LoggerAwareInterface { 'from' => $from, ] ); + // Ignore warnings about master connections/writes...hard to avoid here + $trxProfiler = \Profiler::instance()->getTransactionProfiler(); + $trxProfiler->setSilenced( true ); try { $status = $user->addToDatabase(); if ( !$status->isOk() ) { @@ -1652,6 +1652,7 @@ class AuthManager implements LoggerAwareInterface { return $status; } } catch ( \Exception $ex ) { + $trxProfiler->setSilenced( false ); $this->logger->error( __METHOD__ . ': {username} failed with exception {exception}', [ 'username' => $username, 'exception' => $ex, @@ -1673,9 +1674,10 @@ class AuthManager implements LoggerAwareInterface { // Update user count \DeferredUpdates::addUpdate( new \SiteStatsUpdate( 0, 0, 0, 0, 1 ) ); - // Watch user's userpage and talk page - $user->addWatch( $user->getUserPage(), User::IGNORE_USER_RIGHTS ); + \DeferredUpdates::addCallableUpdate( function () use ( $user ) { + $user->addWatch( $user->getUserPage(), User::IGNORE_USER_RIGHTS ); + } ); // Log the creation if ( $this->config->get( 'NewUserLog' ) ) { @@ -1693,6 +1695,8 @@ class AuthManager implements LoggerAwareInterface { // the newly-created user doesn't get lost. wfGetLBFactory()->commitMasterChanges( __METHOD__ ); + $trxProfiler->setSilenced( false ); + if ( $login ) { $this->setSessionDataForUser( $user ); }