|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Cloggs Smarty Rookie
Joined: 16 May 2003 Posts: 8 Location: United Kingdom
|
Posted: Tue Nov 02, 2004 1:23 pm Post subject: Smarty::load_filter() referencing |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Nov 02, 2004 1:58 pm Post subject: Re: Smarty::load_filter() referencing |
|
|
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 |
|
Cloggs Smarty Rookie
Joined: 16 May 2003 Posts: 8 Location: United Kingdom
|
Posted: Tue Nov 02, 2004 2:35 pm Post subject: Worked around Smarty 'feature' |
|
|
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 |
|
|
|
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
|