From 6958628f0ad7cf41bcef1d0817bc5f119d8e0d37 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 9 Jul 2020 09:37:46 -0700 Subject: [PATCH 1/4] Get QI version from composer.json now --- includes/class_qi.php | 27 +++++++++++++++++++++++---- includes/qi_constants.php | 1 - includes/qi_functions.php | 2 +- index.php | 2 +- modules/qi_create.php | 4 ++-- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/includes/class_qi.php b/includes/class_qi.php index 8512605e..afc18ca1 100644 --- a/includes/class_qi.php +++ b/includes/class_qi.php @@ -50,9 +50,9 @@ public static function page_header($page_title = '') 'S_USER_LANG' => $user->lang['USER_LANG'], 'TRANSLATION_INFO' => $user->lang['TRANSLATION_INFO'], - 'QI_VERSION' => QI_VERSION, + 'QI_VERSION' => self::current_version(), - 'VERSION_CHECK_TITLE' => !empty($update) ? sprintf($user->lang['VERSION_CHECK_TITLE'], $update['current'], QI_VERSION) : '', + 'VERSION_CHECK_TITLE' => !empty($update) ? sprintf($user->lang['VERSION_CHECK_TITLE'], $update['current'], self::current_version()) : '', 'VERSION_CHECK_CURRENT' => !empty($update) ? $update['current'] : '', 'U_VERSION_CHECK_URL' => !empty($update) ? $update['download'] : '', )); @@ -345,7 +345,7 @@ public static function msg_handler($errno, $msg_text, $errfile, $errline) 'MSG_EXPLAIN' => '', 'SETTINGS_FORM' => '', 'RETURN_LINKS' => $l_return_index, - 'QI_VERSION' => QI_VERSION, + 'QI_VERSION' => self::current_version(), 'L_QUICKINSTALL' => $user->lang['QUICKINSTALL'], 'L_PHPBB_QI_TEXT' => $user->lang['PHPBB_QI_TEXT'], 'L_FOR_PHPBB_VERSIONS' => $user->lang['FOR_PHPBB_VERSIONS'], @@ -405,9 +405,28 @@ public static function get_update() $version_helper = new qi_version_helper(); return $version_helper - ->set_current_version(QI_VERSION) + ->set_current_version(self::current_version()) ->force_stability('stable') ->set_file_location('www.phpbb.com', '/customise/db/official_tool/phpbb3_quickinstall', 'version_check') ->get_update(); } + + /** + * Get the current version of QuickInstall from composer.json + * + * @return string + */ + public static function current_version() + { + global $quickinstall_path; + + static $composerJson = null; + + if ($composerJson === null) { + $composerJson = file_get_contents("{$quickinstall_path}composer.json"); + $composerJson = json_decode($composerJson, true); + } + + return $composerJson["version"]; + } } diff --git a/includes/qi_constants.php b/includes/qi_constants.php index 131f83f2..76ea13d3 100644 --- a/includes/qi_constants.php +++ b/includes/qi_constants.php @@ -7,7 +7,6 @@ * */ -define('QI_VERSION', '1.4.0'); //define('QI_DEBUG', true); // un-comment this disable template caching // Cookies set by QI diff --git a/includes/qi_functions.php b/includes/qi_functions.php index d87e3069..25fac9ba 100644 --- a/includes/qi_functions.php +++ b/includes/qi_functions.php @@ -270,7 +270,7 @@ function gen_error_msg($msg_text, $msg_title = 'General Error', $msg_explain = ' 'MSG_EXPLAIN' => $msg_explain, 'SETTINGS_FORM' => $settings_form, 'RETURN_LINKS' => $l_return_index, - 'QI_VERSION' => QI_VERSION, + 'QI_VERSION' => qi::current_version(), 'L_QUICKINSTALL' => $l_quickinstall, 'L_PHPBB_QI_TEXT' => $l_phpbb_qi_text, 'L_FOR_PHPBB_VERSIONS' => $l_for_phpbb_versions, diff --git a/index.php b/index.php index c45ad7f5..dfbbfbb3 100644 --- a/index.php +++ b/index.php @@ -249,7 +249,7 @@ else if (!empty($settings->update_text)) // PROFILE_UPDATED { $update_title = sprintf($user->lang['PROFILE_UPDATED'], $settings->profile); - $update_explain = sprintf($user->lang['UPDATED_EXPLAIN'], QI_VERSION); + $update_explain = sprintf($user->lang['UPDATED_EXPLAIN'], qi::current_version()); $update_msg = '