Re: [SMARTY] The dreaded 'Fatal error: Call to undefined function: ()' error

From: Date: Wed, 31 Jul 2002 08:36:26 +0000
Subject: Re: [SMARTY] The dreaded 'Fatal error: Call to undefined function: ()' error
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5530@lists.php.net to get a copy of this message
On 31 Jul 2002 at 0:46, Tim Fountain wrote: > > But you're right: Smarty should suppress a undefined-function fatal > > error - ie. by checking if a plugin is loaded before calling it in > > the compiled template. > > That's not exactly what I was saying - I was saying Smarty should > display an error if it fails to load a plugin, to prevent the cryptic > error that may occur later when an undefined plugin is called. Smarty always triggers PHP warnings with trigger_error() if it cannot load a plugin. So your requested feature is already implemented -- I don't know why these warning do not show up on your system. Perhaps it is inside a HTML tag so that it is not displayed...? Quoting Monte: ================================================== You should always get other warnings before your "undefined function" errors, something like this: PHP Warning: Smarty plugin error: [in index.tpl line 7]: modifier 'upper' is not implemented in /path/to/Smarty.class.php on line 1958 <br /> PHP Warning: Smarty plugin error: [in index.tpl line 13]: unknown tag - 'html_select_date' in /path/to/Smarty.class.php on line 1958 <br /> ================================================== > On the other hand, your templates may not use the plugin at all so not > being able to load it wouldn't be a problem. It's a tricky one. Smarty is so 'smart' to load plugins only when they are needed in a template. Another Monte's quote: ================================================== If those functions don't get defined (by loading the plugin), then you will get undefined function errors. I don't think it would be correct to supress them, they are errors that happen. In this guys case, he wouldn't have seen any errors, making things even more difficult to debug. ================================================== I don't agree with Monte here: Smarty knows that an undefined- function error will appear if it cannot load a plugin - since it will try to call that function later on. That's why Smarty should trigger a *fatal* error if it cannot load a plugin to prevent a nonsence-fatal like "undefined function '()' in ...." that is confusing and very difficult to debug. If a user sees the error Fatal error: Smarty: failed loading plugin 'xxyyzz' in template .... he immediately knows what's wrong. -- Ferdinand Beyer <fbeyer@clickhand.de>

« previous php.smarty.general (#5530) next »