From 00a771d06f1272849b9ccd6fe576540de5306149 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 12 Apr 2023 11:17:04 +0200 Subject: [PATCH] Improve error reporting for `value=null` in `{plural}` template function Accidental `null`s are a common issue when dealing with database objects, explicitly detect a `null` to not misleadingly report that the `value` attribute is missing. see https://www.woltlab.com/community/thread/299515-fatal-error-nach-update-missing-attribute-value/ --- .../template/plugin/PluralFunctionTemplatePlugin.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/template/plugin/PluralFunctionTemplatePlugin.class.php b/wcfsetup/install/files/lib/system/template/plugin/PluralFunctionTemplatePlugin.class.php index 9c3fcab8e1..5b57962628 100644 --- a/wcfsetup/install/files/lib/system/template/plugin/PluralFunctionTemplatePlugin.class.php +++ b/wcfsetup/install/files/lib/system/template/plugin/PluralFunctionTemplatePlugin.class.php @@ -41,7 +41,11 @@ final class PluralFunctionTemplatePlugin implements IFunctionTemplatePlugin public function execute($tagArgs, TemplateEngine $tplObj) { if (!isset($tagArgs['value'])) { - throw new SystemException("Missing attribute 'value'"); + if (!\array_key_exists('value', $tagArgs)) { + throw new SystemException("Missing attribute 'value'"); + } else { + throw new SystemException("Attribute 'value' must not be null"); + } } if (!isset($tagArgs['other'])) { throw new SystemException("Missing attribute 'other'"); -- 2.20.1