How in the world did we break the database? I mean really. Somehow we broke insert (DatabaseInsertTestCase), merge (DatabaseMergeTestCase), select (DatabaseSelectComplexTestCase), and transaction (DatabaseTransactionTestCase) tests. Probably a side-effect of me changing the exception handling a while back to always wrap a PDOException. Merge probably broke because of insert, because it wraps insert, so probably fixing insert will fix merge.

Someone please fix this.

Comments

Crell’s picture

Issue summary: View changes

Mention broken merge tests, too.

pounard’s picture

Status: Active » Needs review

Whooooot fixed in the 1567438-database-transaction branch!

Niklas Fiekas’s picture

Status: Needs review » Reviewed & tested by the community

Yay, thanks a lot!

I confirmed that the test failures are resolved.

Branch link: 1567438-database-transaction
Commit: 60ebceebf9607a63c

Diff for quick review:

diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php b/core/lib/Drupal/Core/Database/Driver/mysq
index e56da55..2d3fffa 100644
--- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
+++ b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php
@@ -7,6 +7,8 @@
 
 namespace Drupal\Core\Database\Driver\mysql;
 
+use Drupal\Core\Database\DatabaseExceptionWrapper;
+
 use Drupal\Core\Database\Database;
 use Drupal\Core\Database\TransactionCommitFailedException;
 use Drupal\Core\Database\DatabaseException;
@@ -180,7 +182,7 @@ class Connection extends DatabaseConnection {
         try {
           $this->query('RELEASE SAVEPOINT ' . $name);
         }
-        catch (PDOException $e) {
+        catch (DatabaseExceptionWrapper $e) {
           // However, in MySQL (InnoDB), savepoints are automatically committed
           // when tables are altered or created (DDL transactions are not
           // supported). This can cause exceptions due to trying to release
@@ -188,7 +190,7 @@ class Connection extends DatabaseConnection {
           //
           // To avoid exceptions when no actual error has occurred, we silently
           // succeed for MySQL error code 1305 ("SAVEPOINT does not exist").
-          if ($e->errorInfo[1] == '1305') {
+          if ($e->getPrevious()->errorInfo[1] == '1305') {
             // If one SAVEPOINT was released automatically, then all were.
             // Therefore, clean the transaction stack.
             $this->transactionLayers = array();
Crell’s picture

Status: Reviewed & tested by the community » Fixed

Merged. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

And we broke select, too!