From d38f392aa4b9b7e7ab54872d6fb678c0894e9b53 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 17 Oct 2024 16:42:45 +0200 Subject: [PATCH] Add a pre-upgrade check for required PHP extensions Fixes #6021 --- ...oltlab.wcf_6.1_checkSystemRequirements.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) 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); +} -- 2.20.1