From 7d8e97358e40ad365a97ae98e983600e20315c92 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 27 Oct 2023 15:12:33 +0200 Subject: [PATCH] Suppress exceptions for unknown icons outside a dev environments See https://www.woltlab.com/community/thread/302385-unbekanntes-fa-icon-seite-unbrauchbar/ --- .../lib/system/style/FontAwesomeIcon.class.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/style/FontAwesomeIcon.class.php b/wcfsetup/install/files/lib/system/style/FontAwesomeIcon.class.php index a0ef6fbd79..d384658dd3 100644 --- a/wcfsetup/install/files/lib/system/style/FontAwesomeIcon.class.php +++ b/wcfsetup/install/files/lib/system/style/FontAwesomeIcon.class.php @@ -121,9 +121,18 @@ final class FontAwesomeIcon implements IFontAwesomeIcon, \Stringable private static function validateName(string $name): void { - if (!self::isValidName($name)) { - throw new UnknownIcon($name); + if (self::isValidName($name)) { + return; } + + // Do not throw an exception when the debug mode and developer tools + // are disabled. This allows unknown icons to be passed to the template + // which will throw a proper error without bricking the entire page. + if (!\ENABLE_DEBUG_MODE || !\ENABLE_DEVELOPER_TOOLS) { + return; + } + + throw new UnknownIcon($name); } /** -- 2.20.1