diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2011-12-31 16:09:02 -0800 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2011-12-31 16:09:02 -0800 |
commit | d74306729631ead14323638108e3dcdf5f926517 (patch) | |
tree | c0b63517798f274f4c9404b245b0175f3cb08b65 /includes/database | |
parent | 8703bb7b3d83f79c3a1453f17a8f4eb9da9f442f (diff) | |
download | brdo-d74306729631ead14323638108e3dcdf5f926517.tar.gz brdo-d74306729631ead14323638108e3dcdf5f926517.tar.bz2 |
Issue follow-up #1007830 by Damien Tournoud, basic: Fixed Nested transactions throw exceptions when they got out of scope.
Diffstat (limited to 'includes/database')
-rw-r--r-- | includes/database/database.inc | 12 | ||||
-rw-r--r-- | includes/database/mysql/database.inc | 7 | ||||
-rw-r--r-- | includes/database/sqlite/database.inc | 2 |
3 files changed, 14 insertions, 7 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc index 33000aa70..6e40b2765 100644 --- a/includes/database/database.inc +++ b/includes/database/database.inc @@ -1016,9 +1016,9 @@ abstract class DatabaseConnection extends PDO { throw new DatabaseTransactionNoActiveException(); } // A previous rollback to an earlier savepoint may mean that the savepoint - // in question has already been rolled back. - if (!in_array($savepoint_name, $this->transactionLayers)) { - return; + // in question has already been accidentally committed. + if (!isset($this->transactionLayers[$savepoint_name])) { + throw new DatabaseTransactionNoActiveException(); } // We need to find the point we're rolling back to, all other savepoints @@ -1096,8 +1096,12 @@ abstract class DatabaseConnection extends PDO { if (!$this->supportsTransactions()) { return; } + // The transaction has already been committed earlier. There is nothing we + // need to do. If this transaction was part of an earlier out-of-order + // rollback, an exception would already have been thrown by + // Database::rollback(). if (!isset($this->transactionLayers[$name])) { - throw new DatabaseTransactionNoActiveException(); + return; } // Mark this layer as committable. diff --git a/includes/database/mysql/database.inc b/includes/database/mysql/database.inc index a57f7dd02..e024a7f39 100644 --- a/includes/database/mysql/database.inc +++ b/includes/database/mysql/database.inc @@ -183,8 +183,11 @@ class DatabaseConnection_mysql extends DatabaseConnection { // succeed for MySQL error code 1305 ("SAVEPOINT does not exist"). if ($e->errorInfo[1] == '1305') { // If one SAVEPOINT was released automatically, then all were. - // Therefore, we keep just the topmost transaction. - $this->transactionLayers = array('drupal_transaction' => 'drupal_transaction'); + // Therefore, clean the transaction stack. + $this->transactionLayers = array(); + // We also have to explain to PDO that the transaction stack has + // been cleaned-up. + PDO::commit(); } else { throw $e; diff --git a/includes/database/sqlite/database.inc b/includes/database/sqlite/database.inc index 257a9ee16..b4e41b527 100644 --- a/includes/database/sqlite/database.inc +++ b/includes/database/sqlite/database.inc @@ -59,7 +59,7 @@ class DatabaseConnection_sqlite extends DatabaseConnection { $this->statementClass = NULL; // This driver defaults to transaction support, except if explicitly passed FALSE. - $this->transactionSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE; + $this->transactionSupport = $this->transactionalDDLSupport = !isset($connection_options['transactions']) || $connection_options['transactions'] !== FALSE; $this->connectionOptions = $connection_options; |