Re: [SMARTY-DEV] create_function strange behaviour
| From: | Andrei Zmievski | Date: | Tue, 11 Jun 2002 14:15:09 +0000 |
| Subject: | Re: [SMARTY-DEV] create_function strange behaviour | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-136@lists.php.net to get a copy of this message | ||
Using functions created with create_function() is not supported by
Smarty because of the way it mangles the function name. It basically
prepends it with a NULL byte and that's what screws all this up.
On Tue, 11 Jun 2002, Bram van Leur wrote:
> This is probably not a real Smarty bug, but I can only reproduce it's
> strange behaviour with Smarty using the following piece of code:
>
> <?php
> require 'Smarty.class.php';
>
> $smarty = new Smarty;
> $smarty->force_compile = true;
>
> $smarty->register_prefilter(create_function('$a', 'return $a;'));
>
> $smarty->display('a.tpl');
> $smarty->display('b.tpl');
>
> print_r($smarty->_plugins['prefilter']);
> ?>
>
> It gives (with any Smarty 2.* version) an error about calling an
> function without a name. The a and b template just contain one word
> (like foo and bar).
>
> After an hour of hunting this bug I found out that the
> _plugins['prefilter'] contains the following:
> [] => Array('lambda_1', null, null, false)
>
> This is quite strange because of the differing key and function name (as
> first element in the Array). Looking at register_prefilter shows me they
> are both set using the $function parameter. How can they differ?
>
> Next load_plugin messes it up by setting a true to the wrong (new)
> entry. A second run on the same smarty object makes it real fun because
> of a fake (and loaded) plug-in entry.
>
> Anyway, the thing that causes the trouble is the strange return of
> create_function. Can anyone tell me why the $function variable in
> register_prefilter has a different value the 2 times its used in the
> same statement?
>
> --
> Bram v. Leur
> The Netherlands
>
> Proud to PHP!
>
>
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
-Andrei http://www.gravitonic.com/
* There is no knowledge that is not power. -- Ralph Waldo Emerson *