Skip to content

Commit 7ca8937

Browse files
authored
Fix importing database dumps on Alpine Linux (#27)
1 parent 5488f8b commit 7ca8937

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.12.6
4+
### Bugfixes:
5+
- Fix importing database dumps on Alpine Linux
6+
37
## v0.12.5
48
### Changes:
59
- Remove unnecessary `doctrine/annotations` from test suite

phpstan-baseline.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@ parameters:
55
count: 1
66
path: src/Database/DatabaseResetter.php
77

8-
-
9-
message: "#^Method Neusta\\\\Pimcore\\\\TestingFramework\\\\Database\\\\PimcoreInstaller\\:\\:getDataFiles\\(\\) return type has no value type specified in iterable type array\\.$#"
10-
count: 1
11-
path: src/Database/PimcoreInstaller.php
12-
13-
-
14-
message: "#^Method Neusta\\\\Pimcore\\\\TestingFramework\\\\Database\\\\PimcoreInstaller\\:\\:getDataFiles\\(\\) should return array but returns array\\<int, string\\>\\|false\\.$#"
15-
count: 1
16-
path: src/Database/PimcoreInstaller.php
17-
188
-
199
message: "#^Parameter \\#1 \\$sql of method Doctrine\\\\DBAL\\\\Connection\\:\\:executeStatement\\(\\) expects string, string\\|false given\\.$#"
2010
count: 1

src/Database/PimcoreInstaller.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@
1818
class PimcoreInstaller extends Installer
1919
{
2020
private const SQL_FILE_EXTENSION = '.sql';
21-
private const GZIP_FILE_EXTENSION = '.sql.gz';
22-
private const DUMP_FILE_EXTENSIONS = [
23-
self::SQL_FILE_EXTENSION,
24-
self::GZIP_FILE_EXTENSION,
25-
];
21+
private const SQL_GZIP_FILE_EXTENSION = '.sql.gz';
2622

2723
private ?string $dumpLocation = null;
2824

@@ -48,6 +44,8 @@ public function setDumpLocation(string $dumpLocation): void
4844
}
4945

5046
/**
47+
* Todo: remove when support for Pimcore <11.3.3 is dropped.
48+
*
5149
* @param Connection $db
5250
* @param string $file
5351
*
@@ -61,7 +59,8 @@ public function insertDatabaseDump($db, $file = ''): void
6159
$db = Db::get();
6260
}
6361

64-
if (str_ends_with($file, self::GZIP_FILE_EXTENSION)) {
62+
// Todo: remove when support for Pimcore <11.3 is dropped
63+
if (str_ends_with($file, self::SQL_GZIP_FILE_EXTENSION)) {
6564
$file = 'compress.zlib://' . $file;
6665
}
6766

@@ -94,14 +93,22 @@ public function insertDatabaseDump($db, $file = ''): void
9493
$db->update('users', ['id' => 0], ['name' => 'system']);
9594
}
9695

96+
/**
97+
* @return array<string>
98+
*/
9799
protected function getDataFiles(): array
98100
{
99101
if (!$this->dumpLocation) {
100102
return [];
101103
}
102104

103-
$pattern = \sprintf('%s/*{%s}', $this->dumpLocation, implode(',', self::DUMP_FILE_EXTENSIONS));
105+
$files = [
106+
...glob($this->dumpLocation . '/*' . self::SQL_FILE_EXTENSION, \GLOB_NOSORT) ?: [],
107+
...glob($this->dumpLocation . '/*' . self::SQL_GZIP_FILE_EXTENSION, \GLOB_NOSORT) ?: [],
108+
];
109+
110+
natsort($files);
104111

105-
return glob($pattern, \GLOB_BRACE);
112+
return $files;
106113
}
107114
}

0 commit comments

Comments
 (0)