From 598b72301a2cdcd0f3a0c1196f6fc1107e01650e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 31 May 2022 15:11:02 +0200 Subject: [PATCH] Add basic check for the runtime environment Running WoltLab Suite in an unsupported environment might work for the majority of requests, some requests might fail very visibly. But there also is a third type: A request that *appear* to execute properly, but that subtly behaves incorrectly, due to a change in PHP's behavior. The latter type is dangerous, as those requests might introduce errors into the dataset that are very hard to impossible to correct after the fact because the necessary information to fix up the data is no longer available. Prevent this situation from occuring by performing a basic test of the runtime environment and halting processing early if this test fails to ensure that it processed as little as possible. --- wcfsetup/install/files/acp/templates/index.tpl | 4 ++++ .../install/files/acp/templates/packageList.tpl | 4 ++++ .../lib/system/request/RequestHandler.class.php | 15 +++++++++++++++ wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + 5 files changed, 25 insertions(+) diff --git a/wcfsetup/install/files/acp/templates/index.tpl b/wcfsetup/install/files/acp/templates/index.tpl index 64658fda48..e5c9d2dc92 100644 --- a/wcfsetup/install/files/acp/templates/index.tpl +++ b/wcfsetup/install/files/acp/templates/index.tpl @@ -4,6 +4,10 @@

{lang}wcf.global.acp{/lang}

+{if !(50500 <= PHP_VERSION_ID && PHP_VERSION_ID <= 70499)} +
{lang}wcf.global.incompatiblePhpVersion{/lang}
+{/if} + {if TIME_NOW < 1641038400}
{lang}wcf.acp.package.upgradeRequired.expiring{/lang}
{elseif TIME_NOW < 1656676800} diff --git a/wcfsetup/install/files/acp/templates/packageList.tpl b/wcfsetup/install/files/acp/templates/packageList.tpl index ce8f058801..c8682927e6 100644 --- a/wcfsetup/install/files/acp/templates/packageList.tpl +++ b/wcfsetup/install/files/acp/templates/packageList.tpl @@ -58,6 +58,10 @@ {/hascontent} +{if !(50500 <= PHP_VERSION_ID && PHP_VERSION_ID <= 70499)} +
{lang}wcf.global.incompatiblePhpVersion{/lang}
+{/if} + {if TIME_NOW < 1641038400}
{lang}wcf.acp.package.upgradeRequired.expiring{/lang}
{elseif TIME_NOW < 1656676800} diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php index 903138a65e..a8409ce352 100644 --- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php @@ -67,6 +67,8 @@ class RequestHandler extends SingletonFactory { throw new IllegalLinkException(); } } + + $this->checkSystemEnvironment(); // build request $this->buildRequest($application); @@ -100,6 +102,19 @@ class RequestHandler extends SingletonFactory { exit; } } + + private function checkSystemEnvironment() + { + if ($this->isACPRequest()) { + return; + } + + if (!(50500 <= PHP_VERSION_ID && PHP_VERSION_ID <= 70499)) { + \header('HTTP/1.1 500 Internal Server Error'); + + throw new NamedUserException(WCF::getLanguage()->get('wcf.global.incompatiblePhpVersion')); + } + } /** * Builds a new request. diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index ff6eb7e00a..08270a207c 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -3010,6 +3010,7 @@ E-Mail-Adresse: {@$emailAddress} {* this line ends with a space *} + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index e2b637bd97..bba38250ef 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2960,6 +2960,7 @@ Email: {@$emailAddress} {* this line ends with a space *} + -- 2.20.1