From be0718ab9a56ac20ff109c60648017878edf28e2 Mon Sep 17 00:00:00 2001 From: Moshe Weitzman Date: Wed, 12 Jan 2022 10:27:10 -0500 Subject: [PATCH] Fix #5010. sql:dump includes path to sqlite3 database file in result-file=auto filename. Also uses in-memory sqlite during CI. (#5012) --- .circleci/config.yml | 2 +- .ddev/config.yaml | 2 ++ src/Commands/core/SiteInstallCommands.php | 2 ++ src/Sql/SqlBase.php | 7 ++++--- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8ec7c1167b..c8551df2a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -73,7 +73,7 @@ jobs: docker: - image: wodby/php:7.4 environment: - - UNISH_DB_URL=sqlite://sut/sites/dev/files/.ht.sqlite + - "UNISH_DB_URL=sqlite://:memory:" <<: *test74steps test_74_drupal9_postgres: diff --git a/.ddev/config.yaml b/.ddev/config.yaml index d25d9b975a..cd4d76057f 100644 --- a/.ddev/config.yaml +++ b/.ddev/config.yaml @@ -17,4 +17,6 @@ composer_version: "" disable_settings_management: true web_environment: - UNISH_DB_URL=mysql://root:root@db +# - "UNISH_DB_URL=sqlite://:memory:" +# - UNISH_DB_URL=pgsql://postgres:@localhost - DRUSH_OPTIONS_URI=$DDEV_PRIMARY_URL diff --git a/src/Commands/core/SiteInstallCommands.php b/src/Commands/core/SiteInstallCommands.php index 68a288c1c2..9f69175dd9 100644 --- a/src/Commands/core/SiteInstallCommands.php +++ b/src/Commands/core/SiteInstallCommands.php @@ -48,6 +48,8 @@ class SiteInstallCommands extends DrushCommands implements SiteAliasManagerAware * Install using the specified DB params. * @usage drush si --db-url=sqlite://sites/example.com/files/.ht.sqlite * Install using SQLite + * @usage drush si --db-url=sqlite://:memory: + * Install using SQLite in-memory database. * @usage drush si --account-pass=mom * Re-install with specified uid1 password. * @usage drush si --existing-config diff --git a/src/Sql/SqlBase.php b/src/Sql/SqlBase.php index 79a9866e4c..36bf02627a 100644 --- a/src/Sql/SqlBase.php +++ b/src/Sql/SqlBase.php @@ -233,13 +233,14 @@ public function dumpCmd($table_selection): string /* * Generate a path to an output file for a SQL dump when needed. * - * @param string|bool @file + * @param string|bool|null @file * If TRUE, generate a path based on usual backup directory and current date. * Otherwise, just return the path that was provided. */ - public function dumpFile($file) + public function dumpFile($file): ?string { - $database = $this->dbSpec['database']; + // basename() is needed for sqlite as $database is a path. Harmless otherwise. + $database = basename($this->dbSpec['database']); // $file is passed in to us usually via --result-file. If the user // has set $options['result-file'] = 'auto', then we