Made DB commit() method properly bail out if no trx is active
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 25 Jun 2014 17:12:44 +0000 (10:12 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Wed, 25 Jun 2014 17:12:44 +0000 (10:12 -0700)
* Also flipped conditional to avoid being in the negative

Change-Id: I30bce9a015bea5909322bba93493500b5b418d18

includes/db/Database.php

index 7bbcc2f..32a2ca8 100644 (file)
@@ -3467,17 +3467,18 @@ abstract class DatabaseBase implements IDatabase, DatabaseType {
                        );
                }
 
-               if ( $flush !== 'flush' ) {
+               if ( $flush === 'flush' ) {
                        if ( !$this->mTrxLevel ) {
-                               wfWarn( "$fname: No transaction to commit, something got out of sync!" );
-                       } elseif ( $this->mTrxAutomatic ) {
-                               wfWarn( "$fname: Explicit commit of implicit transaction. Something may be out of sync!" );
+                               return; // nothing to do
+                       } elseif ( !$this->mTrxAutomatic ) {
+                               wfWarn( "$fname: Flushing an explicit transaction, getting out of sync!" );
                        }
                } else {
                        if ( !$this->mTrxLevel ) {
+                               wfWarn( "$fname: No transaction to commit, something got out of sync!" );
                                return; // nothing to do
-                       } elseif ( !$this->mTrxAutomatic ) {
-                               wfWarn( "$fname: Flushing an explicit transaction, getting out of sync!" );
+                       } elseif ( $this->mTrxAutomatic ) {
+                               wfWarn( "$fname: Explicit commit of implicit transaction. Something may be out of sync!" );
                        }
                }