From: Marcel Werk Date: Fri, 26 Jan 2024 15:42:16 +0000 (+0100) Subject: Improve error handling if the configured cache source is unavailable X-Git-Tag: 6.1.0_Alpha_1~196^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d34c90a0dd096fb49c6bb2f341b9d964d9f49192;p=GitHub%2FWoltLab%2FWCF.git Improve error handling if the configured cache source is unavailable Closes #5720 --- diff --git a/wcfsetup/install/files/lib/system/acp/dashboard/box/StatusMessageAcpDashboardBox.class.php b/wcfsetup/install/files/lib/system/acp/dashboard/box/StatusMessageAcpDashboardBox.class.php index 4f15526538..06c24434da 100644 --- a/wcfsetup/install/files/lib/system/acp/dashboard/box/StatusMessageAcpDashboardBox.class.php +++ b/wcfsetup/install/files/lib/system/acp/dashboard/box/StatusMessageAcpDashboardBox.class.php @@ -7,6 +7,7 @@ use wcf\system\acp\dashboard\box\event\PHPExtensionCollecting; use wcf\system\acp\dashboard\box\event\StatusMessageCollecting; use wcf\system\application\ApplicationHandler; use wcf\system\cache\builder\PackageUpdateCacheBuilder; +use wcf\system\cache\CacheHandler; use wcf\system\Environment; use wcf\system\event\EventHandler; use wcf\system\registry\RegistryHandler; @@ -139,6 +140,13 @@ final class StatusMessageAcpDashboardBox extends AbstractAcpDashboardBox } } + if (!CacheHandler::getInstance()->sanityCheck()) { + $messages[] = new StatusMessage( + StatusMessageType::Error, + WCF::getLanguage()->getDynamicVariable('wcf.acp.index.cacheSanityCheckFailed') + ); + } + return $messages; } diff --git a/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php b/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php index 65277a6631..d9ec9af9c7 100644 --- a/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php +++ b/wcfsetup/install/files/lib/system/cache/CacheHandler.class.php @@ -152,4 +152,21 @@ class CacheHandler extends SingletonFactory return $parameters; } + + /** + * Returns false, if the configured cache source type could not be initialized. + * + * @since 6.1 + */ + public function sanityCheck(): bool + { + if ( + CACHE_SOURCE_TYPE != 'disk' + && \get_class(CacheHandler::getInstance()->getCacheSource()) === \wcf\system\cache\source\DiskCacheSource::class + ) { + return false; + } + + return true; + } } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index fc98ef5842..f0b3db6aa8 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -971,6 +971,7 @@ Sie erreichen das Fehlerprotokoll unter: {link controller='ExceptionLogView' isE Liste der fehlenden Texte für weitere Informationen.]]> Systemüberprüfung durchzuführen.]]> + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 8f07fe3b13..2670df39fb 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -949,6 +949,7 @@ You can access the error log at: {link controller='ExceptionLogView' isEmail=tru list of missing phrases for more information.]]> System Check.]]> +