diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2011-08-01 20:51:29 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2011-08-01 20:51:29 -0700 |
commit | d676fe412c46c94ed2497b1ca47de42cd0177c3b (patch) | |
tree | d397d999bc3238c474829c44b744e985b31e9808 /includes/database/mysql | |
parent | a6d722568f44306170ba084cba88bdeb1573bf3b (diff) | |
download | brdo-d676fe412c46c94ed2497b1ca47de42cd0177c3b.tar.gz brdo-d676fe412c46c94ed2497b1ca47de42cd0177c3b.tar.bz2 |
Issue #1185780 by Damien Tournoud: Fixed Make transactions more flexible and useful.
Diffstat (limited to 'includes/database/mysql')
-rw-r--r-- | includes/database/mysql/database.inc | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/includes/database/mysql/database.inc b/includes/database/mysql/database.inc index 157cbfa56..0d9158789 100644 --- a/includes/database/mysql/database.inc +++ b/includes/database/mysql/database.inc @@ -137,21 +137,16 @@ class DatabaseConnection_mysql extends DatabaseConnection { /** * Overridden to work around issues to MySQL not supporting transactional DDL. */ - public function popTransaction($name) { - if (!$this->supportsTransactions()) { - return; - } - if (!$this->inTransaction()) { - throw new DatabaseTransactionNoActiveException(); - } - - // Commit everything since SAVEPOINT $name. - while ($savepoint = array_pop($this->transactionLayers)) { - if ($savepoint != $name) { - continue; + protected function popCommittableTransactions() { + // Commit all the committable layers. + foreach (array_reverse($this->transactionLayers) as $name => $active) { + // Stop once we found an active transaction. + if ($active) { + break; } // If there are no more layers left then we should commit. + unset($this->transactionLayers[$name]); if (empty($this->transactionLayers)) { if (!PDO::commit()) { throw new DatabaseTransactionCommitFailedException(); @@ -173,13 +168,12 @@ class DatabaseConnection_mysql extends DatabaseConnection { 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'); + $this->transactionLayers = array('drupal_transaction' => 'drupal_transaction'); } else { throw $e; } } - break; } } } |