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

Smarty::load_filter() referencing

 
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
Cloggs
Smarty Rookie


Joined: 16 May 2003
Posts: 8
Location: United Kingdom

PostPosted: Tue Nov 02, 2004 1:23 pm    Post subject: Smarty::load_filter() referencing Reply with quote

In my code design I have extended the Smarty class and use $smarty->auto_loadfilters to invoke a number of output filters. Noticed that in one of the filters the reference to Smarty is not the original smarty instance setup.

Look at Smarty::fetch() where autofilters are loaded through Smarty::load_filter(). Then look at Smarty::load_filter() which contains the line
Code:
smarty_core_load_plugins($_params, $this).
Looked at the source for the plugin and saw it defined as function
Code:
smarty_core_load_plugins($params, &$smarty).


Think the Smarty::load_filter() to the plugin should read
Code:
smarty_core_load_plugins($_params, &$this).
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Nov 02, 2004 1:58 pm    Post subject: Re: Smarty::load_filter() referencing Reply with quote

Cloggs wrote:
Think the Smarty::load_filter() to the plugin should read
Code:
smarty_core_load_plugins($_params, &$this).


no, it shouldn't. call-time-pass-by-reference is bad. which is why it is deprecated.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Cloggs
Smarty Rookie


Joined: 16 May 2003
Posts: 8
Location: United Kingdom

PostPosted: Tue Nov 02, 2004 2:35 pm    Post subject: Worked around Smarty 'feature' Reply with quote

Granted that call-time-pass-by-reference is deprecated and one of these great PhP debates which I consider to be outside the Smarty discussion domain.

Despite this my config Php 4.3.8 and Smarty 2.6.6 initiates a new Smarty instance when calling output filters defined through auto_loadfilter.

In my MVC design with a single controller class instance extends from the main Smarty class that Smarty behaviour is undesirable.

I patched it by replacing the Smarty reference passed to my output filter function
Code:
smarty_outputfilter_evaluate($sHtml,&$oSmarty)
with the global reference to the controller class
Code:
$oSmarty =& $GLOBALS['oController'];
to get it working.
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