From 7797bef59ab8ac853ab4fa587121307ffd354a8e Mon Sep 17 00:00:00 2001 From: "alejandro.campos@artica.es" Date: Tue, 19 Mar 2024 16:52:09 +0100 Subject: [PATCH] check history db mysql version in update --- pandora_console/required_um_versions.php | 1 + .../lib/UpdateManager/Client.php | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/pandora_console/required_um_versions.php b/pandora_console/required_um_versions.php index 0543377f87..f6f7ae5afa 100644 --- a/pandora_console/required_um_versions.php +++ b/pandora_console/required_um_versions.php @@ -3,3 +3,4 @@ // Versions must be specified as a string in the following formats: '8', '8.0.30', ... $php_version = '8.2'; $mysql_version = '8'; +$mysql_version_history = '8'; diff --git a/pandora_console/update_manager_client/lib/UpdateManager/Client.php b/pandora_console/update_manager_client/lib/UpdateManager/Client.php index 5431c0b58c..57208baf19 100644 --- a/pandora_console/update_manager_client/lib/UpdateManager/Client.php +++ b/pandora_console/update_manager_client/lib/UpdateManager/Client.php @@ -1498,6 +1498,45 @@ class Client if ($filepath !== null) { include $filepath; + if ((bool) $config['history_db_enabled'] === true) { + if (isset($config['history_db_connection']) === false + || $config['history_db_connection'] === false + ) { + ob_start(); + $config['history_db_connection'] = db_connect( + $config['history_db_host'], + $config['history_db_name'], + $config['history_db_user'], + io_output_password($config['history_db_pass']), + $config['history_db_port'], + false + ); + ob_get_clean(); + } + + if ($config['history_db_connection'] !== false) { + $curr_mysql_version_hist = @mysql_db_process_sql( + 'SELECT VERSION() AS version', + 'affected_rows', + $config['history_db_connection'], + false + ); + + $curr_mysql_version_hist = $curr_mysql_version_hist[0]['version']; + + if (is_string($curr_mysql_version_hist) === true + && empty($curr_mysql_version_hist) === false + ) { + if (isset($mysql_version_history) === true + && is_string($mysql_version_history) === true + && $this->compareVersions($curr_mysql_version_hist, $mysql_version_history) < 0 + ) { + throw new \Exception('MySQL version (history database) >= '.$mysql_version_history.' is required'); + } + } + } + } + $curr_php_version = phpversion(); $curr_mysql_version = db_get_value_sql('SELECT VERSION() AS version');