diff --git a/includes/database/database.inc b/includes/database/database.inc index b45711f154138dcba0705af59e52a72303ac5dd8..326e1c05c32be3d3a22ce927cbf5a7e33d600d7a 100644 --- a/includes/database/database.inc +++ b/includes/database/database.inc @@ -225,7 +225,7 @@ abstract class DatabaseConnection extends PDO { * * @var boolean */ - protected $willRollBack; + protected $willRollback; /** * The name of the Select class for this connection. @@ -849,12 +849,12 @@ public function startTransaction($required = FALSE) { * * This method throws an exception if no transaction is active. */ - public function rollBack() { + public function rollback() { if ($this->transactionLayers == 0) { throw new NoActiveTransactionException(); } - $this->willRollBack = TRUE; + $this->willRollback = TRUE; } /** @@ -867,12 +867,12 @@ public function rollBack() { * @return * TRUE if the transaction will roll back, FALSE otherwise. */ - public function willRollBack() { + public function willRollback() { if ($this->transactionLayers == 0) { throw new NoActiveTransactionException(); } - return $this->willRollBack; + return $this->willRollback; } /** @@ -1448,6 +1448,23 @@ public function __destruct() { $this->connection->popTransaction(); } + /** + * Roll back the current transaction. + * + * This is just a wrapper method to rollback whatever transaction stack we + * are currently in, which is managed by the connection object itself. + */ + public function rollback() { + $this->connection->rollback(); + } + + /** + * Determine if this transaction will roll back. + */ + public function willRollback() { + return $this->connection->willRollback(); + } + } /** diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test index 3d6a4ebce3af0c5cbef13d52040ecca284c98f81..51b110db9aeaeedad363800977ff5493b21974da 100644 --- a/modules/simpletest/tests/database_test.test +++ b/modules/simpletest/tests/database_test.test @@ -2624,8 +2624,8 @@ class DatabaseTransactionTestCase extends DatabaseTestCase { if ($rollback) { // Roll back the transaction, if requested. // This rollback should propagate to the the outer transaction, if present. - $connection->rollBack(); - $this->assertTrue($connection->willRollBack(), t('Transaction is scheduled to roll back after calling rollBack().')); + $txn->rollback(); + $this->assertTrue($txn->willRollback(), t('Transaction is scheduled to roll back after calling rollback().')); } }