diff --git a/pandora_console/required_um_versions.php b/pandora_console/required_um_versions.php new file mode 100644 index 0000000000..ba8e16a5d1 --- /dev/null +++ b/pandora_console/required_um_versions.php @@ -0,0 +1,5 @@ + $v2_part) { + // $version1 is newer. + return 1; + } + } + + // Versions are identical. + return 0; + } + + /** * Update files. * @@ -1426,6 +1460,8 @@ class Client bool $classic=false, bool $called_recursively=false ) :void { + global $config; + if (is_dir($from) !== true || is_readable($from) !== true) { throw new \Exception('Cannot access patch files '.$from); } @@ -1445,6 +1481,41 @@ class Client throw new \Exception('Files are not readable'); } + // External path to required versions file. + $download_filepath = $this->tmpDir.'/downloads/'.$version.'/required_um_versions.php'; + + // Fallback file path in console root. + $local_filepath = $config['homedir'].'/required_um_versions.php'; + + $filepath = null; + + if (file_exists($download_filepath) === true) { + $filepath = $download_filepath; + } else if (file_exists($local_filepath) === true) { + $filepath = $local_filepath; + } + + if ($filepath !== null) { + include $filepath; + + $curr_php_version = phpversion(); + $curr_mysql_version = db_get_value_sql('SELECT VERSION() AS version'); + + if (isset($php_version) === true + && is_string($php_version) === true + && $this->compareVersions($curr_php_version, $php_version) < 0 + ) { + throw new \Exception('PHP version >= '.$php_version.' is required'); + } + + if (isset($mysql_version) === true + && is_string($mysql_version) === true + && $this->compareVersions($curr_mysql_version, $mysql_version) < 0 + ) { + throw new \Exception('MySQL version >= '.$mysql_version.' is required'); + } + } + if ($test === true && $called_recursively === false) { // Get size of folder and its subfolders corresponding to "from" path containing those files // that will be updated in product.