Check explicitly for `false` before raising an unknown error

This commit is contained in:
Yonas Habteab 2023-09-12 17:01:31 +02:00 committed by Johannes Meyer
parent 4b2784f85e
commit 13569a34b7
1 changed files with 5 additions and 5 deletions

View File

@ -126,10 +126,14 @@ class DbMigration
{
if (! $this->query) {
$statements = @file_get_contents($this->getScriptPath());
if (! $statements) {
if ($statements === false) {
throw new RuntimeException(sprintf('Cannot load upgrade script %s', $this->getScriptPath()));
}
if (empty($statements)) {
throw new RuntimeException('Nothing to migrate');
}
if (preg_match('/\s*delimiter\s*(\S+)\s*$/im', $statements, $matches)) {
/** @var string $statements */
$statements = preg_replace('/\s*delimiter\s*(\S+)\s*$/im', '', $statements);
@ -140,10 +144,6 @@ class DbMigration
$this->query = $statements;
}
if (empty($this->query)) {
throw new RuntimeException('Nothing to migrate');
}
$conn->exec($this->query);
return $this;