diff --git a/library/Icinga/Application/Hook/Common/DbMigration.php b/library/Icinga/Application/Hook/Common/DbMigration.php index 14219be58..a115e10d1 100644 --- a/library/Icinga/Application/Hook/Common/DbMigration.php +++ b/library/Icinga/Application/Hook/Common/DbMigration.php @@ -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;