Improve error message in UserFunctionTemplatePlugin
authorMatthias Schmidt <gravatronics@live.com>
Tue, 26 May 2020 14:39:45 +0000 (16:39 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 26 May 2020 14:39:45 +0000 (16:39 +0200)
See #3321

wcfsetup/install/files/lib/system/template/plugin/UserFunctionTemplatePlugin.class.php

index ad6d9ec58a53f8e830723695f6af25fa70fb2f75..5b56dd2c52229ab6661038a6cf117656bd3603b0 100644 (file)
@@ -43,7 +43,12 @@ class UserFunctionTemplatePlugin implements IFunctionTemplatePlugin {
                $object = $tagArgs['object'];
                unset($tagArgs['object']);
                if (!($object instanceof UserProfile) && !ClassUtil::isDecoratedInstanceOf($object, UserProfile::class)) {
-                       throw new \InvalidArgumentException("'object' attribute is no '" . UserProfile::class . "' object.");
+                       $type = gettype($object);
+                       if (is_object($object)) {
+                               $type = "'" . get_class($object) . "' object";
+                       }
+                       
+                       throw new \InvalidArgumentException("'object' attribute is no '" . UserProfile::class . "' object, instead {$type} given.");
                }
                
                $additionalParameters = '';