From 0073e148527730307c7da89d0785690924a6532c Mon Sep 17 00:00:00 2001 From: catch Date: Mon, 29 Jun 2020 16:16:28 +0100 Subject: [PATCH] Issue #3145412 by pavnish, cburschka, amateescu: Connection::__destruct() can't delete the sqlite file --- core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php index 44ef57c6bcb2..1fa1fcdc220b 100644 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php +++ b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php @@ -187,9 +187,9 @@ class Connection extends DatabaseConnection { // We can prune the database file if it doesn't have any tables. if ($count == 0 && $this->connectionOptions['database'] != ':memory:' && file_exists($this->connectionOptions['database'] . '-' . $prefix)) { - // Detaching the database fails at this point, but no other queries - // are executed after the connection is destructed so we can simply - // remove the database file. + // Detach the database. + $this->query('DETACH DATABASE :schema', [':schema' => $prefix]); + // Destroy the database file. unlink($this->connectionOptions['database'] . '-' . $prefix); } }