From 48b47a4a8ba0260d52226c80063ebac081fa719b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 22 Feb 2021 12:27:17 +0100 Subject: [PATCH] Check system requirements before starting the upgrade Resolves #4008 --- com.woltlab.wcf/package.xml | 17 +++++-- ...oltlab.wcf_5.4_checkSystemRequirements.php | 48 +++++++++++++++++++ 2 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_checkSystemRequirements.php diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index 79ab03a9b0..932197b82d 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -51,9 +51,19 @@ + + files_pre_check.tar + + + acp/update_com.woltlab.wcf_5.4_checkSystemRequirements.php + acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php + files_pre.tar - - - acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php - + acp/update_com.woltlab.wcf_5.4_session_1_cookies.php acp/update_com.woltlab.wcf_5.4_session_2_user_session.php diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_checkSystemRequirements.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_checkSystemRequirements.php new file mode 100644 index 0000000000..65dcbdfa60 --- /dev/null +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_checkSystemRequirements.php @@ -0,0 +1,48 @@ + + * @package WoltLabSuite\Core + */ + +use wcf\system\WCF; + +$phpVersion = \PHP_VERSION; +$neededPhpVersion = '7.2.24'; +if (!\version_compare($phpVersion, $neededPhpVersion, '>=')) { + if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { + $message = "Ihre PHP-Version '{$phpVersion}' ist unzureichend für die Installation dieser Software. PHP-Version {$neededPhpVersion} oder höher wird benötigt."; + } else { + $message = "Your PHP version '{$phpVersion}' is insufficient for installation of this software. PHP version {$neededPhpVersion} or greater is required."; + } + + throw new \RuntimeException($message); +} + +$sqlVersion = WCF::getDB()->getVersion(); +$compareSQLVersion = \preg_replace('/^(\d+\.\d+\.\d+).*$/', '\\1', $sqlVersion); +if (\stripos($sqlVersion, 'MariaDB') !== false) { + $neededSqlVersion = '10.1.44'; + $sqlFork = 'MariaDB'; +} else { + $sqlFork = 'MySQL'; + if ($compareSQLVersion[0] === '5') { + $neededSqlVersion = '5.7.31'; + } else { + $neededSqlVersion = '8.0.19'; + } +} + +if (!\version_compare($compareSQLVersion, $neededSqlVersion, '>=')) { + if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { + $message = "Ihre {$sqlFork}-Version '{$sqlVersion}' ist unzureichend für die Installation dieser Software. {$sqlFork}-Version {$neededSqlVersion} oder höher wird benötigt."; + } else { + $message = "Your {$sqlFork} version '{$sqlVersion}' is insufficient for installation of this software. {$sqlFork} version {$neededSqlVersion} or greater is required."; + } + + throw new \RuntimeException($message); +} -- 2.20.1