From: Alexander Ebert Date: Thu, 17 Oct 2024 14:42:45 +0000 (+0200) Subject: Add a pre-upgrade check for required PHP extensions X-Git-Tag: 6.1.0~12 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d38f392aa4b9b7e7ab54872d6fb678c0894e9b53;p=GitHub%2FWoltLab%2FWCF.git Add a pre-upgrade check for required PHP extensions Fixes #6021 --- diff --git a/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_checkSystemRequirements.php b/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_checkSystemRequirements.php index d6521c53f4..5ce55a85ea 100644 --- a/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_checkSystemRequirements.php +++ b/wcfsetup/install/files/acp/update_com.woltlab.wcf_6.1_checkSystemRequirements.php @@ -35,3 +35,29 @@ if (!$checkForTls()) { throw new \RuntimeException($message); } + +$requiredPhpExtensions = \array_filter( + [ + 'openssl' => \extension_loaded('openssl'), + 'gmp' => !\extension_loaded('gmp'), + ], + static fn($value) => $value === false +); + +if ($requiredPhpExtensions !== []) { + $missingPhpExtensions = \implode( + ", ", + \array_map( + static fn(string $extension) => "'{$extension}'", + \array_keys($requiredPhpExtensions) + ) + ); + + if (WCF::getLanguage()->getFixedLanguageCode() === 'de') { + $message = "Die folgenden PHP-Erweiterungen werden für den Betrieb der Software benötigt: " . $missingPhpExtensions; + } else { + $message = "The following PHP extensions are required to run the software: " . $missingPhpExtensions; + } + + throw new \RuntimeException($message); +}