diff -u b/core/modules/system/system.install b/core/modules/system/system.install --- b/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -12,6 +12,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\Core\Cache\Cache; use Drupal\Core\Database\Database; +use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\DrupalKernel; use Drupal\Core\Entity\ContentEntityTypeInterface; use Drupal\Core\Entity\EntityTypeInterface; @@ -2522,10 +2523,10 @@ } } -/** +/* * Fix any orphan sequences created from column changes in PostgreSQL. */ -function system_update_8802(&$sandbox) { +function system_update_8806(&$sandbox) { $connection = \Drupal::database(); if ($connection->databaseType() !== 'pgsql') { // This database update is a no-op for all other core database drivers. @@ -2616,7 +2617,7 @@ $sandbox['fixed']++; } - catch (\Drupal\Core\Database\DatabaseExceptionWrapper $e) { + catch (DatabaseExceptionWrapper $e) { $transaction->rollBack(); } } @@ -2642 +2642,0 @@ - reverted: --- b/core/tests/Drupal/FunctionalTests/Core/Database/PostgreSqlSequenceUpdateTest.php +++ /dev/null @@ -1,47 +0,0 @@ -databaseDumpFiles = [ - __DIR__ . '/../../../../../modules/system/tests/fixtures/update/drupal-8.6.0.bare.testing.php.gz', - __DIR__ . '/../../../../../modules/system/tests/fixtures/update/drupal-8.pgsql-orphan-sequence.php', - ]; - } - - /** - * Asserts that a newly created sequence has the correct ownership. - */ - public function testPostgreSqlSequenceUpdate() { - $database = $this->container->get('database'); - $db_type = $database->databaseType(); - - // Run the updates. - $this->runUpdates(); - - if ($db_type === 'pgsql') { - $sequenceExists = (bool) $database - ->query("SELECT pg_get_serial_sequence('{" . $database->prefixTables('pgsql_sequence_test') . "}', 'sequence_field')") - ->fetchField(); - $this->assertTrue($sequenceExists, 'Sequence is owned by the table and column.'); - } - else { - $this->assertTrue(TRUE, 'Database update ran successfully on non-pgsql driver.'); - } - } - -} only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -84,7 +84,10 @@ public function exists($name) { public function read($name) { $data = FALSE; try { - $raw = $this->connection->query('SELECT data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name', [':collection' => $this->collection, ':name' => $name], $this->options)->fetchField(); + $raw = $this->connection->query('SELECT data FROM {' . $this->connection->escapeTable($this->table) . '} WHERE collection = :collection AND name = :name ORDER BY collection, name', [ + ':collection' => $this->collection, + ':name' => $name, + ], $this->options)->fetchField(); if ($raw !== FALSE) { $data = $this->decode($raw); } only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/tests/src/Functional/Database/PostgreSqlSequenceUpdateTest.php @@ -0,0 +1,47 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../fixtures/update/drupal-8.6.0.bare.testing.php.gz', + __DIR__ . '/../../../fixtures/update/drupal-8.pgsql-orphan-sequence.php', + ]; + } + + /** + * Asserts that a newly created sequence has the correct ownership. + */ + public function testPostgreSqlSequenceUpdate() { + $database = $this->container->get('database'); + $db_type = $database->databaseType(); + + // Run the updates. + $this->runUpdates(); + + if ($db_type === 'pgsql') { + $sequenceExists = (bool) $database + ->query("SELECT pg_get_serial_sequence('{" . $database->prefixTables('pgsql_sequence_test') . "}', 'sequence_field')") + ->fetchField(); + $this->assertTrue($sequenceExists, 'Sequence is owned by the table and column.'); + } + else { + $this->assertTrue(TRUE, 'Database update ran successfully on non-pgsql driver.'); + } + } + +}