diff --git a/core/modules/system/system.install b/core/modules/system/system.install index b8a478cc3818d00e54ed55277d58c8356c30f1c2..079fa6cbf7e9be0b563c1d806e0423048128a8ae 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1823,6 +1823,12 @@ function system_update_10100(&$sandbox = NULL) { }); if ($connection->databaseType() != 'sqlite') { foreach (array_keys($cache_tables) as $table) { + // If the table has no expire column there is nothing to do. This can + // happen if a site has tables starting with cache_ that are not cache + // bins. + if (!$schema->fieldExists($table, 'expire')) { + continue; + } // Truncate cache tables. They will be flushed anyway at the end of // database updates, but emptying the tables now will boost the schema // changes. diff --git a/core/modules/system/tests/src/Functional/Update/Y2038TimestampUpdateTest.php b/core/modules/system/tests/src/Functional/Update/Y2038TimestampUpdateTest.php index 7da0497a627f9bbecdf35d9948db6715add8d2eb..d81f8ff8fcfffafa28e4419f6053d8fca611c21a 100644 --- a/core/modules/system/tests/src/Functional/Update/Y2038TimestampUpdateTest.php +++ b/core/modules/system/tests/src/Functional/Update/Y2038TimestampUpdateTest.php @@ -95,6 +95,17 @@ public function testUpdate() { $this->markTestSkipped("This test does not support the SQLite database driver."); } + // Create a table starting with cache that is not a cache bin. + \Drupal::service('database')->schema()->createTable('cache_bogus', [ + 'fields' => [ + 'id' => [ + 'type' => 'int', + 'not null' => TRUE, + ], + ], + 'primary key' => ['id'], + ]); + $this->collectTimestampFieldsFromDatabase(); // PostgreSQL returns the value 'integer' instead of 'int' when queried // about the column type. Some PostgreSQL tables are already of the type @@ -120,7 +131,7 @@ public function collectTimestampFieldsFromDatabase() { } $tables = $connection->schema()->findTables('cache_%'); $tables = array_filter($tables, function ($table) { - return str_starts_with($table, 'cache_'); + return str_starts_with($table, 'cache_') && $table !== 'cache_bogus'; }); $this->assertNotEmpty($tables); foreach ($tables as $table) {