summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/database/database.inc23
-rw-r--r--includes/database/mysql/database.inc4
-rw-r--r--modules/simpletest/tests/database_test.test43
3 files changed, 4 insertions, 66 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc
index 53732a982..1dc89fd14 100644
--- a/includes/database/database.inc
+++ b/includes/database/database.inc
@@ -873,17 +873,9 @@ abstract class DatabaseConnection extends PDO {
/**
* Returns a new DatabaseTransaction object on this connection.
*
- * @param $required
- * If executing an operation that absolutely must use transactions, specify
- * TRUE for this parameter. If the connection does not support transactions,
- * this method will throw an exception and the operation will not be possible.
* @see DatabaseTransaction
*/
- public function startTransaction($required = FALSE) {
- if ($required && !$this->supportsTransactions()) {
- throw new TransactionsNotSupportedException();
- }
-
+ public function startTransaction() {
if (empty($this->transactionClass)) {
$this->transactionClass = 'DatabaseTransaction_' . $this->driver();
if (!class_exists($this->transactionClass)) {
@@ -1601,18 +1593,7 @@ abstract class Database {
}
/**
- * Exception to mark databases that do not support transations.
- *
- * This exception will be thrown when a transaction is started that does not
- * allow for the "silent fallback" of no transaction and the database connection
- * in use does not support transactions. The calling code must then take
- * appropriate action.
- */
-class TransactionsNotSupportedException extends Exception { }
-
-/**
- * Exception to throw when popTransaction() is called when no transaction is
- * active.
+ * Exception to throw when popTransaction() is called when no transaction is active.
*/
class NoActiveTransactionException extends Exception { }
diff --git a/includes/database/mysql/database.inc b/includes/database/mysql/database.inc
index bbe4ea70e..437d796e3 100644
--- a/includes/database/mysql/database.inc
+++ b/includes/database/mysql/database.inc
@@ -14,8 +14,8 @@
class DatabaseConnection_mysql extends DatabaseConnection {
public function __construct(array $connection_options = array()) {
- // This driver defaults to non transaction support.
- $this->transactionSupport = !empty($connection_options['transactions']);
+ // This driver defaults to transaction support, except if explicitly passed FALSE.
+ $this->transactionSupport = !isset($connection_options['transactions']) || ($connection_options['transactions'] !== FALSE);
// MySQL never supports transactional DDL.
$this->transactionalDDLSupport = FALSE;
diff --git a/modules/simpletest/tests/database_test.test b/modules/simpletest/tests/database_test.test
index 4af00e69f..19ecbe6e9 100644
--- a/modules/simpletest/tests/database_test.test
+++ b/modules/simpletest/tests/database_test.test
@@ -2908,49 +2908,6 @@ class DatabaseTransactionTestCase extends DatabaseTestCase {
}
/**
- * Test that a database that claims to support transactions will return a transaction object.
- *
- * If the active connection does not support transactions, this test does nothing.
- */
- function testTransactionsSupported() {
- try {
- $connection = Database::getConnection();
- if ($connection->supportsTransactions()) {
-
- // Start a "required" transaction. This should fail if we do
- // this on a database that does not actually support transactions.
- $txn = db_transaction(TRUE);
- }
- $this->pass('Transaction started successfully.');
- }
- catch (TransactionsNotSupportedException $e) {
- $this->fail("Exception thrown when it shouldn't have been.");
- }
- }
-
- /**
- * Test that a database that doesn't support transactions fails correctly.
- *
- * If the active connection supports transactions, this test does nothing.
- */
- function testTransactionsNotSupported() {
- try {
- $connection = Database::getConnection();
- if (!$connection->supportsTransactions()) {
-
- // Start a "required" transaction. This should fail if we do this
- // on a database that does not actually support transactions, and
- // the current database does claim to NOT support transactions.
- $txn = db_transaction(TRUE);
- $this->fail('No transaction failure registered.');
- }
- }
- catch (TransactionsNotSupportedException $e) {
- $this->pass('Exception thrown for unsupported transactions.');
- }
- }
-
- /**
* Test transaction rollback on a database that supports transactions.
*
* If the active connection does not support transactions, this test does nothing.