diff --git a/application/controllers/MigrationsController.php b/application/controllers/MigrationsController.php index ca2c83f4c..1a6fc6a27 100644 --- a/application/controllers/MigrationsController.php +++ b/application/controllers/MigrationsController.php @@ -203,8 +203,8 @@ class MigrationsController extends CompatController } else { Notification::error( $this->translate( - 'Applied migrations successfully. Though, one or more migration hooks failed to run.' - . ' See logs for details' + 'Applied migrations successfully. Though, one or more migration hooks' + . ' failed to run. See logs for details' ) ); } diff --git a/library/Icinga/Application/Hook/MigrationHook.php b/library/Icinga/Application/Hook/MigrationHook.php index 9e31f3421..1811b9839 100644 --- a/library/Icinga/Application/Hook/MigrationHook.php +++ b/library/Icinga/Application/Hook/MigrationHook.php @@ -86,7 +86,8 @@ abstract class MigrationHook implements Countable { $pdoStmt = $conn->prepexec( sprintf( - "SELECT %s AS column_type, %s AS column_length FROM information_schema.columns WHERE table_name = ? AND column_name = ?", + 'SELECT %s AS column_type, %s AS column_length FROM information_schema.columns' + . ' WHERE table_name = ? AND column_name = ?', $conn->getAdapter() instanceof Pgsql ? 'udt_name' : 'column_type', $conn->getAdapter() instanceof Pgsql ? 'character_maximum_length' : 'NULL' ), @@ -140,7 +141,7 @@ abstract class MigrationHook implements Countable $this->load(); } - return $this->migrations; + return $this->migrations ?? []; } /** @@ -289,8 +290,12 @@ abstract class MigrationHook implements Countable } } - // Sort all the migrations by their version numbers in ascending order. - uksort($this->migrations, 'version_compare'); + if ($this->migrations) { + // Sort all the migrations by their version numbers in ascending order. + uksort($this->migrations, function ($a, $b) { + return version_compare($a, $b); + }); + } } /**