From 7e32413b06c41cfeae91ec0a2190d81529064412 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Fri, 5 Jan 2018 14:47:59 -0800 Subject: [PATCH] Fixed #2274 --- CHANGELOG-v3.md | 1 + src/db/mysql/Schema.php | 10 +++++----- src/db/pgsql/Schema.php | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index b2a69319d76..26106836f1e 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -7,6 +7,7 @@ ### Fixed - Fixed the position of asset folder toggles. ([#2264](https://github.com/craftcms/cms/issues/2264)) +- Fixed a bug where default Craft database backups and restores would fail if there was a space in the file path. ([#2274](https://github.com/craftcms/cms/issues/2274)) ## 3.0.0-RC4 - 2018-01-02 diff --git a/src/db/mysql/Schema.php b/src/db/mysql/Schema.php index c815bd542f4..c503c21a231 100644 --- a/src/db/mysql/Schema.php +++ b/src/db/mysql/Schema.php @@ -153,7 +153,7 @@ public function getDefaultBackupCommand(): string } $defaultArgs = - ' --defaults-extra-file='.$this->_createDumpConfigFile(). + ' --defaults-extra-file="'.$this->_createDumpConfigFile().'"'. ' --add-drop-table'. ' --comments'. ' --create-options'. @@ -167,7 +167,7 @@ public function getDefaultBackupCommand(): string $defaultArgs. ' --single-transaction'. ' --no-data'. - ' --result-file={file}'. + ' --result-file="{file}"'. ' {database}'; $dataDump = 'mysqldump'. @@ -175,7 +175,7 @@ public function getDefaultBackupCommand(): string ' --no-create-info'. implode('', $defaultTableIgnoreList). ' {database}'. - ' >> {file}'; + ' >> "{file}"'; return $schemaDump.' && '.$dataDump; } @@ -188,9 +188,9 @@ public function getDefaultBackupCommand(): string public function getDefaultRestoreCommand(): string { return 'mysqldump'. - ' --defaults-extra-file='.$this->_createDumpConfigFile(). + ' --defaults-extra-file="'.$this->_createDumpConfigFile().'"'. ' {database}'. - ' < {file}'; + ' < "{file}"'; } /** diff --git a/src/db/pgsql/Schema.php b/src/db/pgsql/Schema.php index 5f644fe6903..585e7d8d506 100644 --- a/src/db/pgsql/Schema.php +++ b/src/db/pgsql/Schema.php @@ -153,7 +153,7 @@ public function getDefaultBackupCommand() ' --username={user}'. ' --if-exists'. ' --clean'. - ' --file={file}'. + ' --file="{file}"'. ' --schema={schema}'. implode('', $defaultTableIgnoreList); } @@ -171,7 +171,7 @@ public function getDefaultRestoreCommand(): string ' --port={port}'. ' --username={user}'. ' --no-password'. - ' < {file}'; + ' < "{file}"'; } /**