Skip to content
Snippets Groups Projects
Commit 562a13e2 authored by catch's avatar catch
Browse files

Issue #3181013 by Driskell, alexpott, ericgsmith, Pan Lee, smustgrave, Kristen...

Issue #3181013 by Driskell, alexpott, ericgsmith, Pan Lee, smustgrave, Kristen Pol, mxr576: Faulty permanent config cache has been set to the cache backend on failed sql server connection

(cherry picked from commit 201fd312)
parent d8f4305d
Branches
Tags
20 merge requests!8376Drupal views: adding more granularity to the ‘use ajax’ functionality,!8300Issue #3443586 View area displays even when parent view has no results.,!7567Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7565Issue #3153723 by quietone, Hardik_Patel_12: Change the scaffolding...,!7509Change label "Block description" to "Block type",!7344Issue #3292350 by O'Briat, KlemenDEV, hswong3i, smustgrave, quietone: Update...,!6922Issue #3412959 by quietone, smustgrave, longwave: Fix 12 'un' words,!6848Issue #3417553 by longwave: Remove withConsecutive() in CacheCollectorTest,!6720Revert "Issue #3358581 by pfrenssen, _tarik_, a.dmitriiev, smustgrave:...,!6560Update ClaroPreRender.php, confirming classes provided are in array format,!6528Issue #3414261 by catch: Add authenticated user umami performance tests,!6501Issue #3263668 by omkar-pd, Wim Leers, hooroomoo: Re-enable inline form errors...,!6354Draft: Issue #3380392 by phma: Updating language weight from the overview reverts label if translated,!6324Issue #3416723 by Ludo.R: Provide a "node type" views default argument,!6119Issue #3405704 by Spokje, longwave: symfony/psr-http-message-bridge major version bump,!5950Issue #3403653 by alexpott, longwave: Incorporate improvements to how contrib runs PHPStan to core,!5858Issue #3401971 by fjgarlin: Test-only job shouldn't require constant rebases...,!5716Draft: Issue #3401102 by Spokje, longwave, smustgrave: Nightwatch artifacts on GitLab not retained,!5674Transaction autocommit during shutdown relies on unreliable object destruction order,!5644Issue #3395563 by nireneko, marvil07, lauriii, borisson_, smustgrave, Wim...
Pipeline #55627 canceled
Pipeline: drupal

#55628

    ......@@ -72,8 +72,11 @@ public function exists($name) {
    ], $this->options)->fetchField();
    }
    catch (\Exception $e) {
    // If we attempt a read without actually having the database or the table
    // available, just return FALSE so the caller can handle it.
    if ($this->connection->schema()->tableExists($this->table)) {
    throw $e;
    }
    // If we attempt a read without actually having the table available,
    // return false so the caller can handle it.
    return FALSE;
    }
    }
    ......@@ -90,8 +93,11 @@ public function read($name) {
    }
    }
    catch (\Exception $e) {
    // If we attempt a read without actually having the database or the table
    // available, just return FALSE so the caller can handle it.
    if ($this->connection->schema()->tableExists($this->table)) {
    throw $e;
    }
    // If we attempt a read without actually having the table available,
    // return false so the caller can handle it.
    }
    return $data;
    }
    ......@@ -108,8 +114,11 @@ public function readMultiple(array $names) {
    }
    }
    catch (\Exception $e) {
    // If we attempt a read without actually having the database or the table
    // available, just return an empty array so the caller can handle it.
    if ($this->connection->schema()->tableExists($this->table)) {
    throw $e;
    }
    // If we attempt a read without actually having the table available,
    // return an empty array so the caller can handle it.
    }
    return $list;
    }
    ......@@ -277,6 +286,11 @@ public function listAll($prefix = '') {
    return $query->execute()->fetchCol();
    }
    catch (\Exception $e) {
    if ($this->connection->schema()->tableExists($this->table)) {
    throw $e;
    }
    // If we attempt a read without actually having the table available,
    // return an empty array so the caller can handle it.
    return [];
    }
    }
    ......@@ -295,6 +309,11 @@ public function deleteAll($prefix = '') {
    ->execute();
    }
    catch (\Exception $e) {
    if ($this->connection->schema()->tableExists($this->table)) {
    throw $e;
    }
    // If we attempt a delete without actually having the table available,
    // return false so the caller can handle it.
    return FALSE;
    }
    }
    ......@@ -328,6 +347,11 @@ public function getAllCollectionNames() {
    ])->fetchCol();
    }
    catch (\Exception $e) {
    if ($this->connection->schema()->tableExists($this->table)) {
    throw $e;
    }
    // If we attempt a read without actually having the table available,
    // return an empty array so the caller can handle it.
    return [];
    }
    }
    ......
    ......@@ -4,6 +4,7 @@
    use Drupal\Core\Config\DatabaseStorage;
    use Drupal\Core\Database\Database;
    use Drupal\Core\Database\DatabaseExceptionWrapper;
    /**
    * Tests DatabaseStorage operations.
    ......@@ -39,4 +40,87 @@ protected function delete($name) {
    Database::getConnection()->delete('config')->condition('name', $name)->execute();
    }
    /**
    * Tests that operations throw exceptions if the query fails.
    */
    public function testExceptionIsThrownIfQueryFails() {
    $connection = Database::getConnection();
    if ($connection->databaseType() === 'sqlite') {
    // See: https://www.drupal.org/project/drupal/issues/3349286
    $this->markTestSkipped('SQLite cannot allow detection of exceptions due to double quoting.');
    return;
    }
    Database::getConnection()->schema()->dropTable('config');
    // In order to simulate database issue create a table with an incorrect
    // specification.
    $table_specification = [
    'fields' => [
    'id' => [
    'type' => 'int',
    'default' => NULL,
    ],
    ],
    ];
    Database::getConnection()->schema()->createTable('config', $table_specification);
    try {
    $this->storage->exists('config.settings');
    $this->fail('Expected exception not thrown from exists()');
    }
    catch (DatabaseExceptionWrapper $e) {
    // Exception was expected
    }
    try {
    $this->storage->read('config.settings');
    $this->fail('Expected exception not thrown from read()');
    }
    catch (DatabaseExceptionWrapper $e) {
    // Exception was expected
    }
    try {
    $this->storage->readMultiple(['config.settings', 'config.settings2']);
    $this->fail('Expected exception not thrown from readMultiple()');
    }
    catch (DatabaseExceptionWrapper $e) {
    // Exception was expected
    }
    try {
    $this->storage->write('config.settings', ['data' => '']);
    $this->fail('Expected exception not thrown from deleteAll()');
    }
    catch (DatabaseExceptionWrapper $e) {
    // Exception was expected
    }
    try {
    $this->storage->listAll();
    $this->fail('Expected exception not thrown from listAll()');
    }
    catch (DatabaseExceptionWrapper $e) {
    // Exception was expected
    }
    try {
    $this->storage->deleteAll();
    $this->fail('Expected exception not thrown from deleteAll()');
    }
    catch (DatabaseExceptionWrapper $e) {
    // Exception was expected
    }
    try {
    $this->storage->getAllCollectionNames();
    $this->fail('Expected exception not thrown from getAllCollectionNames()');
    }
    catch (DatabaseExceptionWrapper $e) {
    // Exception was expected
    }
    $this->assertTrue(TRUE);
    }
    }
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment