'1_0_1', '1.0.2' => '1_0_2', '1.0.3' => '1_0_3', '1.0.4' => '1_0_4', '1.0.5' => '1_0_5', '1.0.6' => '1_0_6', '1.0.7' => '1_0_7', '1.0.8' => '1_0_8', '1.0.9' => '1_0_9', '1.1.0' => '1_1_0', '1.1.1' => '1_1_1', '1.2.0' => '1_2_0', '1.2.1' => '1_2_1', '1.2.2' => '1_2_2', '1.2.3' => '1_2_3', '1.2.4' => '1_2_4', '1.2.5' => '1_2_5', ]; public static function getClassName($version_class) { return "\AC_SYNC\Includes\Classes\Sql\Version\Action_Wear_Sql_Version_" . $version_class; } public static function getCurrentVersioningScript() { $current_version = get_option('_ACTIONWEAR_DB_VERSION'); // No stored version: nothing to migrate from. Without this guard every // migration is replayed from the first entry of the list, and a missing // migration class fatals on the init hook, taking down the whole site. if (empty($current_version)) { update_option('_ACTIONWEAR_DB_VERSION', Action_Wear_Sql_Manager::DB_VERSION); return; } foreach (self::REGISTERED_VERSIONS as $version => $version_class) { if (version_compare($version, $current_version, "<=")) continue; $class_name = self::getClassName($version_class); if (!class_exists($class_name)) { Log::write("Migrazione DB {$version} non trovata ({$class_name}), saltata", Log::ERROR, Log::CONTEXT_GENERAL); continue; } try { $v = new $class_name; $v::versioningScript(); $v->updateVersionDb($version); } catch (\Throwable $th) { // log error to db Log::write("Error during DB upgrade, " . $th->getMessage(), Log::CRITICAL, Log::CONTEXT_GENERAL); } } } } }