From: Tim Düsterhus Date: Wed, 12 Apr 2023 09:17:04 +0000 (+0200) Subject: Improve error reporting for `value=null` in `{plural}` template function X-Git-Tag: 6.0.0_Alpha_1~261^2~6^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=00a771d06f1272849b9ccd6fe576540de5306149;p=GitHub%2FWoltLab%2FWCF.git 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/ --- 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'");