From 95665d47a2c4f1d53c4f601d9798ef65925caf49 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Wed, 4 Sep 2024 19:17:29 +0200 Subject: [PATCH] Fix importing database dumps on Alpine Linux Alpine Linux does not support `GLOB_BRACE`. --- CHANGELOG.md | 4 ++++ src/Database/PimcoreInstaller.php | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5186925..a16f01c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v0.12.5 +### Bugfixes: +- Fix importing database dumps on Alpine Linux + ## v0.12.4 ### Bugfixes: - Fix type definition for `ConfgureExtension` diff --git a/src/Database/PimcoreInstaller.php b/src/Database/PimcoreInstaller.php index 46b451a..8acc5e4 100644 --- a/src/Database/PimcoreInstaller.php +++ b/src/Database/PimcoreInstaller.php @@ -18,11 +18,7 @@ class PimcoreInstaller extends Installer { private const SQL_FILE_EXTENSION = '.sql'; - private const GZIP_FILE_EXTENSION = '.sql.gz'; - private const DUMP_FILE_EXTENSIONS = [ - self::SQL_FILE_EXTENSION, - self::GZIP_FILE_EXTENSION, - ]; + private const SQL_GZIP_FILE_EXTENSION = '.sql.gz'; private ?string $dumpLocation = null; @@ -48,6 +44,8 @@ public function setDumpLocation(string $dumpLocation): void } /** + * Todo: remove when support for Pimcore <11.3.3 is dropped + * * @param Connection $db * @param string $file * @@ -61,7 +59,8 @@ public function insertDatabaseDump($db, $file = ''): void $db = Db::get(); } - if (str_ends_with($file, self::GZIP_FILE_EXTENSION)) { + // Todo: remove when support for Pimcore <11.3 is dropped + if (str_ends_with($file, self::SQL_GZIP_FILE_EXTENSION)) { $file = 'compress.zlib://' . $file; } @@ -100,8 +99,13 @@ protected function getDataFiles(): array return []; } - $pattern = \sprintf('%s/*{%s}', $this->dumpLocation, implode(',', self::DUMP_FILE_EXTENSIONS)); + $files = [ + ...glob($this->dumpLocation.'/*'.self::SQL_FILE_EXTENSION, GLOB_NOSORT), + ...glob($this->dumpLocation.'/*'.self::SQL_GZIP_FILE_EXTENSION, GLOB_NOSORT), + ]; + + natsort($files); - return glob($pattern, \GLOB_BRACE); + return $files; } }