Check system requirements before starting the upgrade
authorTim Düsterhus <duesterhus@woltlab.com>
Mon, 22 Feb 2021 11:27:17 +0000 (12:27 +0100)
committerTim Düsterhus <duesterhus@woltlab.com>
Mon, 22 Feb 2021 16:07:05 +0000 (17:07 +0100)
Resolves #4008

com.woltlab.wcf/package.xml
wcfsetup/install/files/acp/update_com.woltlab.wcf_5.4_checkSystemRequirements.php [new file with mode: 0644]

index 79ab03a9b0c649f5dfe5e72bb4f43287e7ddbd70..932197b82d74f7d544c6b01d8ce28d03a70854a3 100644 (file)
        </instructions>
        
        <instructions type="update" fromversion="5.3.*">
+               <!--
+tar cvf com.woltlab.wcf/files_pre_check.tar -C wcfsetup/install/files/ \
+       acp/update_com.woltlab.wcf_5.4_checkSystemRequirements.php \
+       acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php
+               -->
+               <instruction type="file" run="standalone">files_pre_check.tar</instruction>
+               
+               <!-- Checks that need to happen before the upgrade starts. -->
+               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_checkSystemRequirements.php</instruction>
+               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php</instruction>
+
                <!--
 tar cvf com.woltlab.wcf/files_pre.tar -C wcfsetup/install/files/ \
-       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 \
        acp/update_com.woltlab.wcf_5.4_session_3_migrate_session.php \
@@ -63,10 +73,7 @@ tar cvf com.woltlab.wcf/files_pre.tar -C wcfsetup/install/files/ \
        lib/system/package/plugin/FilePackageInstallationPlugin.class.php
                -->
                <instruction type="file" run="standalone">files_pre.tar</instruction>
-               
-               <!-- Checks that need to happen before the upgrade starts. -->
-               <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_checkOwnerGroup.php</instruction>
-               
+
                <!-- Preparations for the new session system. -->
                <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_session_1_cookies.php</instruction>
                <instruction type="script" run="standalone">acp/update_com.woltlab.wcf_5.4_session_2_user_session.php</instruction>
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 (file)
index 0000000..65dcbdf
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+/**
+ * Checks the increased system requirements.
+ *
+ * @author  Tim Duesterhus
+ * @copyright   2001-2021 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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&uuml;r die Installation dieser Software. PHP-Version {$neededPhpVersion} oder h&ouml;her wird ben&ouml;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&uuml;r die Installation dieser Software. {$sqlFork}-Version {$neededSqlVersion} oder h&ouml;her wird ben&ouml;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);
+}