[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Make TransactionProfiler::setSilenced() calls handle nesting
jenkins-bot has submitted this change and it was merged. Change subject: Make TransactionProfiler::setSilenced() calls handle nesting .. Make TransactionProfiler::setSilenced() calls handle nesting Change-Id: I6511a72a0fb921468a8a19ceb4d0a8ae669aa6e4 --- M includes/auth/AuthManager.php M includes/libs/rdbms/TransactionProfiler.php M includes/libs/rdbms/loadbalancer/LoadBalancer.php M includes/specials/SpecialConfirmemail.php M includes/specials/SpecialEmailInvalidate.php 5 files changed, 14 insertions(+), 10 deletions(-) Approvals: Florianschmidtwelzow: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/auth/AuthManager.php b/includes/auth/AuthManager.php index e223e16..eeb233e 100644 --- a/includes/auth/AuthManager.php +++ b/includes/auth/AuthManager.php @@ -1678,7 +1678,7 @@ // Ignore warnings about master connections/writes...hard to avoid here $trxProfiler = \Profiler::instance()->getTransactionProfiler(); - $trxProfiler->setSilenced( true ); + $old = $trxProfiler->setSilenced( true ); try { $status = $user->addToDatabase(); if ( !$status->isOK() ) { @@ -1704,7 +1704,7 @@ return $status; } } catch ( \Exception $ex ) { - $trxProfiler->setSilenced( false ); + $trxProfiler->setSilenced( $old ); $this->logger->error( __METHOD__ . ': {username} failed with exception {exception}', [ 'username' => $username, 'exception' => $ex, @@ -1743,7 +1743,7 @@ $logEntry->insert(); } - $trxProfiler->setSilenced( false ); + $trxProfiler->setSilenced( $old ); if ( $login ) { $this->setSessionDataForUser( $user ); diff --git a/includes/libs/rdbms/TransactionProfiler.php b/includes/libs/rdbms/TransactionProfiler.php index 12f6df5..bf5e299 100644 --- a/includes/libs/rdbms/TransactionProfiler.php +++ b/includes/libs/rdbms/TransactionProfiler.php @@ -80,11 +80,15 @@ } /** -* @param bool $value +* @param bool $value New value +* @return bool Old value * @since 1.28 */ public function setSilenced( $value ) { + $old = $this->silenced; $this->silenced = $value; + + return $old; } /** diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 083dcd6..32df19d 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -1324,7 +1324,7 @@ $cache->makeGlobalKey( __CLASS__, 'server-read-only', $masterServer ), self::TTL_CACHE_READONLY, function () use ( $domain, $conn ) { - $this->trxProfiler->setSilenced( true ); + $old = $this->trxProfiler->setSilenced( true ); try { $dbw = $conn ?: $this->getConnection( self::DB_MASTER, [], $domain ); $readOnly = (int)$dbw->serverIsReadOnly(); @@ -1334,7 +1334,7 @@ } catch ( DBError $e ) { $readOnly = 0; } - $this->trxProfiler->setSilenced( false ); + $this->trxProfiler->setSilenced( $old ); return $readOnly; }, [ 'pcTTL' => $cache::TTL_PROC_LONG, 'busyValue' => 0 ] diff --git a/includes/specials/SpecialConfirmemail.php b/includes/specials/SpecialConfirmemail.php index 7b4e9db..f494b9d 100644 --- a/includes/specials/SpecialConfirmemail.php +++ b/includes/specials/SpecialConfirmemail.php @@ -69,9 +69,9 @@ $this->getOutput()->addWikiMsg( 'confirmemail_noemail' ); } } else { - $trxProfiler->setSilenced( true ); + $old = $trxProfiler->setSilenced( true ); $this->attemptConfirm( $code ); - $trxProfiler->setSilenced( false ); + $trxProfiler->setSilenced( $old ); } } diff --git a/includes/specials/SpecialEmailInvalidate.php b/includes/specials/SpecialEmailInvalidate.php index d2e3e7f..c54abad 100644 --- a/includes/specials/SpecialEmailInvalidate.php +++ b/includes/specials/SpecialEmailInvalidate.php @@ -45,9 +45,9 @@
[MediaWiki-commits] [Gerrit] mediawiki/core[master]: Make TransactionProfiler::setSilenced() calls handle nesting
Aaron Schulz has uploaded a new change for review. https://gerrit.wikimedia.org/r/315614 Change subject: Make TransactionProfiler::setSilenced() calls handle nesting .. Make TransactionProfiler::setSilenced() calls handle nesting Change-Id: I6511a72a0fb921468a8a19ceb4d0a8ae669aa6e4 --- M includes/auth/AuthManager.php M includes/libs/rdbms/TransactionProfiler.php M includes/libs/rdbms/loadbalancer/LoadBalancer.php M includes/specials/SpecialConfirmemail.php M includes/specials/SpecialEmailInvalidate.php 5 files changed, 14 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/14/315614/1 diff --git a/includes/auth/AuthManager.php b/includes/auth/AuthManager.php index e223e16..eeb233e 100644 --- a/includes/auth/AuthManager.php +++ b/includes/auth/AuthManager.php @@ -1678,7 +1678,7 @@ // Ignore warnings about master connections/writes...hard to avoid here $trxProfiler = \Profiler::instance()->getTransactionProfiler(); - $trxProfiler->setSilenced( true ); + $old = $trxProfiler->setSilenced( true ); try { $status = $user->addToDatabase(); if ( !$status->isOK() ) { @@ -1704,7 +1704,7 @@ return $status; } } catch ( \Exception $ex ) { - $trxProfiler->setSilenced( false ); + $trxProfiler->setSilenced( $old ); $this->logger->error( __METHOD__ . ': {username} failed with exception {exception}', [ 'username' => $username, 'exception' => $ex, @@ -1743,7 +1743,7 @@ $logEntry->insert(); } - $trxProfiler->setSilenced( false ); + $trxProfiler->setSilenced( $old ); if ( $login ) { $this->setSessionDataForUser( $user ); diff --git a/includes/libs/rdbms/TransactionProfiler.php b/includes/libs/rdbms/TransactionProfiler.php index 12f6df5..bf5e299 100644 --- a/includes/libs/rdbms/TransactionProfiler.php +++ b/includes/libs/rdbms/TransactionProfiler.php @@ -80,11 +80,15 @@ } /** -* @param bool $value +* @param bool $value New value +* @return bool Old value * @since 1.28 */ public function setSilenced( $value ) { + $old = $this->silenced; $this->silenced = $value; + + return $old; } /** diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 083dcd6..32df19d 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -1324,7 +1324,7 @@ $cache->makeGlobalKey( __CLASS__, 'server-read-only', $masterServer ), self::TTL_CACHE_READONLY, function () use ( $domain, $conn ) { - $this->trxProfiler->setSilenced( true ); + $old = $this->trxProfiler->setSilenced( true ); try { $dbw = $conn ?: $this->getConnection( self::DB_MASTER, [], $domain ); $readOnly = (int)$dbw->serverIsReadOnly(); @@ -1334,7 +1334,7 @@ } catch ( DBError $e ) { $readOnly = 0; } - $this->trxProfiler->setSilenced( false ); + $this->trxProfiler->setSilenced( $old ); return $readOnly; }, [ 'pcTTL' => $cache::TTL_PROC_LONG, 'busyValue' => 0 ] diff --git a/includes/specials/SpecialConfirmemail.php b/includes/specials/SpecialConfirmemail.php index 7b4e9db..f494b9d 100644 --- a/includes/specials/SpecialConfirmemail.php +++ b/includes/specials/SpecialConfirmemail.php @@ -69,9 +69,9 @@ $this->getOutput()->addWikiMsg( 'confirmemail_noemail' ); } } else { - $trxProfiler->setSilenced( true ); + $old = $trxProfiler->setSilenced( true ); $this->attemptConfirm( $code ); - $trxProfiler->setSilenced( false ); + $trxProfiler->setSilenced( $old ); } } diff --git a/includes/specials/SpecialEmailInvalidate.php b/includes/specials/SpecialEmailInvalidate.php index d2e3e7f..c54abad 100644 --- a/includes/specials/SpecialEmailInvalidate.php +++ b/includes/specials/SpecialEmailInvalidate.php