Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

registerPlugin does not support closures [Patch included]

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs
View previous topic :: View next topic  
Author Message
za_creature
Smarty Rookie


Joined: 17 Nov 2010
Posts: 6

PostPosted: Tue Feb 07, 2012 7:53 pm    Post subject: registerPlugin does not support closures [Patch included] Reply with quote

Hello
When registering a plugin with a PHP 5.3+ Closure object, compilation will fail with an error that's somewhere in the lines of "Could not convert object of type Closure to string". Since smarty supports the callback-like array($object, "methodName") construct, adding support for closures is trivial (a Closure is represented as an instance of the class Closure, that implements the __invoke() magic method). Since I'm using it as a block plugin, I've only made the modifications to smarty_internal_compile_private_registered_block.php, but the same code should hold for other plugin types.

[Edit] Patch can be found here: https://gist.github.com/1761969


Last edited by za_creature on Tue Feb 07, 2012 9:10 pm; edited 1 time in total
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Tue Feb 07, 2012 8:29 pm    Post subject: Reply with quote

please paste your diff to http://gist.github.com
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Tue Feb 07, 2012 8:35 pm    Post subject: Reply with quote

we are aware of this. The issue is on the todo list for Smarty 3.2. There are a couple more things to do than simply apply your patch. What about functions, modifiers, filters, …

we're working on it… but it'll take a while.
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
za_creature
Smarty Rookie


Joined: 17 Nov 2010
Posts: 6

PostPosted: Tue Feb 07, 2012 9:22 pm    Post subject: Reply with quote

Heh, there always is something more to do than just apply a patch (even if it's just regression testing). I just posted this in the unlikely event that you guys didn't know about it. Sometimes, developers (myself included) overlook even the most obvious bugs due to focusing on complex ways in which things can go wrong.
I know that the patch only fixes block plugins (well, at least as far as my tests show), but on the off chance that it'd be useful, I thought I'd include it as well.
I'm in no rush to see this fixed, I will be using the above mentioned patch until such a time as Smarty 3.2 is released (when, should the issue persist, I'll just patch that version as well).
Anyway, great job on the best PHP template engine that I know of, and good luck getting this fixed in the next major version.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Bugs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP