jenkins-bot has submitted this change and it was merged. Change subject: Converted DatabaseBase::mTrxAtomicLevels to an array ......................................................................
Converted DatabaseBase::mTrxAtomicLevels to an array * This simplifies the code and cleans up __construct() a bit while also making it less likely to cause trouble with unit testing mocks. * Also add a sanity mTrxLevel check around usage of mTrxAtomicLevels in the one place it was missing Change-Id: Ia0a7f22f5c27b3d4d8b51e04629f42a1ed9c3993 --- M includes/db/Database.php 1 file changed, 10 insertions(+), 12 deletions(-) Approvals: Parent5446: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/db/Database.php b/includes/db/Database.php index 4bbb491..05d1934 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -124,9 +124,9 @@ /** * Array of levels of atomicity within transactions * - * @var SplStack + * @var array */ - private $mTrxAtomicLevels; + private $mTrxAtomicLevels = array(); /** * Record if the current transaction was started implicitly by DatabaseBase::startAtomic @@ -608,8 +608,6 @@ */ function __construct( array $params ) { global $wgDBprefix, $wgDBmwschema, $wgCommandLineMode, $wgDebugDBTransactions; - - $this->mTrxAtomicLevels = new SplStack; $server = $params['host']; $user = $params['user']; @@ -3395,7 +3393,7 @@ } } - $this->mTrxAtomicLevels->push( $fname ); + $this->mTrxAtomicLevels[] = $fname; } /** @@ -3413,13 +3411,13 @@ if ( !$this->mTrxLevel ) { throw new DBUnexpectedError( $this, 'No atomic transaction is open.' ); } - if ( $this->mTrxAtomicLevels->isEmpty() || - $this->mTrxAtomicLevels->pop() !== $fname + if ( !$this->mTrxAtomicLevels || + array_pop( $this->mTrxAtomicLevels ) !== $fname ) { throw new DBUnexpectedError( $this, 'Invalid atomic section ended.' ); } - if ( $this->mTrxAtomicLevels->isEmpty() && $this->mTrxAutomaticAtomic ) { + if ( !$this->mTrxAtomicLevels && $this->mTrxAutomaticAtomic ) { $this->commit( $fname, 'flush' ); } } @@ -3443,7 +3441,7 @@ global $wgDebugDBTransactions; if ( $this->mTrxLevel ) { // implicit commit - if ( !$this->mTrxAtomicLevels->isEmpty() ) { + if ( $this->mTrxAtomicLevels ) { // If the current transaction was an automatic atomic one, then we definitely have // a problem. Same if there is any unclosed atomic level. throw new DBUnexpectedError( $this, @@ -3491,7 +3489,7 @@ $this->mTrxDoneWrites = false; $this->mTrxAutomatic = false; $this->mTrxAutomaticAtomic = false; - $this->mTrxAtomicLevels = new SplStack; + $this->mTrxAtomicLevels = array(); $this->mTrxIdleCallbacks = array(); $this->mTrxPreCommitCallbacks = array(); $this->mTrxShortId = wfRandomString( 12 ); @@ -3524,7 +3522,7 @@ * @throws DBUnexpectedError */ final public function commit( $fname = __METHOD__, $flush = '' ) { - if ( !$this->mTrxAtomicLevels->isEmpty() ) { + if ( $this->mTrxLevel && $this->mTrxAtomicLevels ) { // There are still atomic sections open. This cannot be ignored throw new DBUnexpectedError( $this, @@ -3610,7 +3608,7 @@ $this->doRollback( $fname ); $this->mTrxIdleCallbacks = array(); // cancel $this->mTrxPreCommitCallbacks = array(); // cancel - $this->mTrxAtomicLevels = new SplStack; + $this->mTrxAtomicLevels = array(); if ( $this->mTrxDoneWrites ) { $this->getTransactionProfiler()->transactionWritingOut( $this->mServer, $this->mDBname, $this->mTrxShortId ); -- To view, visit https://gerrit.wikimedia.org/r/243476 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia0a7f22f5c27b3d4d8b51e04629f42a1ed9c3993 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits