From: Chad Horohoe Date: Fri, 6 Aug 2010 12:54:39 +0000 (+0000) Subject: Remove dupe implementations of begin/commit from Postgres. Also included checks for... X-Git-Tag: 1.31.0-rc.0~35672 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=d6c112d38d86946711cb38c82ce8e4e77d151bba;p=lhc%2Fweb%2Fwiklou.git Remove dupe implementations of begin/commit from Postgres. Also included checks for $mTrxLevel on commit/rollback, based on patch on bug 24629 --- diff --git a/includes/db/Database.php b/includes/db/Database.php index 948b9bf0f3..f6756e95b9 100644 --- a/includes/db/Database.php +++ b/includes/db/Database.php @@ -1982,8 +1982,10 @@ abstract class DatabaseBase { * End a transaction */ function commit( $fname = 'Database::commit' ) { - $this->query( 'COMMIT', $fname ); - $this->mTrxLevel = 0; + if( $this->mTrxLevel ) { + $this->query( 'COMMIT', $fname ); + $this->mTrxLevel = 0; + } } /** @@ -1991,8 +1993,10 @@ abstract class DatabaseBase { * No-op on non-transactional databases. */ function rollback( $fname = 'Database::rollback' ) { - $this->query( 'ROLLBACK', $fname, true ); - $this->mTrxLevel = 0; + if( $this->mTrxLevel ) { + $this->query( 'ROLLBACK', $fname, true ); + $this->mTrxLevel = 0; + } } /** diff --git a/includes/db/DatabasePostgres.php b/includes/db/DatabasePostgres.php index af5f30c95c..34bf99cc71 100644 --- a/includes/db/DatabasePostgres.php +++ b/includes/db/DatabasePostgres.php @@ -1282,16 +1282,6 @@ SQL; return pg_field_type( $res, $index ); } - function begin( $fname = 'DatabasePostgres::begin' ) { - $this->query( 'BEGIN', $fname ); - $this->mTrxLevel = 1; - } - - function commit( $fname = 'DatabasePostgres::commit' ) { - $this->query( 'COMMIT', $fname ); - $this->mTrxLevel = 0; - } - /* Not even sure why this is used in the main codebase... */ function limitResultForUpdate( $sql, $num ) { return $sql;