From 115c3565867599f120497e68af5cba5beadcd916 Mon Sep 17 00:00:00 2001 From: fdalex Date: Fri, 26 Nov 2021 15:12:07 +0100 Subject: [PATCH] PHP 7.2+ compatibility Function each() is deprecated since PHP 7.2 and will be removed in PHP 8.0. Replaced each() function by an equivalent so there are no more deprecation errors when running the migration command line. Tested with PHP 7.4.25, CakePHP 2.10.24 --- Lib/MigrationVersion.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lib/MigrationVersion.php b/Lib/MigrationVersion.php index 5d3d38d5..8999d26c 100644 --- a/Lib/MigrationVersion.php +++ b/Lib/MigrationVersion.php @@ -252,7 +252,8 @@ public function getMapping($type, $cache = true) { ksort($mapping); foreach ($mapping as $version => $migration) { - list($name, $class) = each($migration); + $class = reset($migration); + $name = key($migration); $mapping[$version] = array( 'version' => $version, 'name' => $name, 'class' => $class, @@ -439,7 +440,8 @@ protected function _initMigrations() { if (!in_array($db->fullTableName('schema_migrations', false, false), $db->listSources())) { $map = $this->_enumerateMigrations('migrations'); - list($name, $class) = each($map[1]); + $class = reset($map[1]); + $name = key($map[1]); $migration = $this->getMigration($name, $class, 'Migrations'); $migration->run('up'); $this->setVersion(1, 'Migrations');