Skip to content

Commit

Permalink
Fix importing database dumps on Alpine Linux
Browse files Browse the repository at this point in the history
Alpine Linux does not support `GLOB_BRACE`.
  • Loading branch information
jdreesen committed Sep 4, 2024
1 parent 97ffe41 commit 95665d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
20 changes: 12 additions & 8 deletions src/Database/PimcoreInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
*
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;
}
}

0 comments on commit 95665d4

Please sign in to comment.