|
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 |
jacky256 Smarty n00b
Joined: 07 Jul 2015 Posts: 2
|
Posted: Tue Jul 07, 2015 11:14 pm Post subject: New Bug in tag compiler, after last SMARTY update |
|
|
Hi! This is my first post, so please be forgiving.
After updating my CMS to newest version, i found bug:
Error:
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template ....
unknown tag "private_print_expression"'
...
in libs/sysplugins/smarty_internal_templatecompilerbase.php on line 425;
Reason is that classes prepared by composer are uppercase each word, while smarty looks for classes with only first letter uppercase.
My proposition of fix(\smarty\smarty\libs\sysplugins\smarty_internal_templatecompilerbase.php):
Code: | public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null)
{
// re-use object if already exists
if (!isset($this->_tag_objects[$tag])) {
// lazy load internal compiler plugin
$tag=explode('_', $tag);
$tag=array_map(function($word) { return ucfirst($word); }, $tag);
$tag=implode('_',$tag);
$class_name = 'Smarty_Internal_Compile_' . $tag;
if (class_exists($class_name) && (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))) {
$this->_tag_objects[$tag] = new $class_name;
} else {
$this->_tag_objects[$tag] = false;
return false;
}
}
// compile this tag
return $this->_tag_objects[$tag] === false ? false : $this->_tag_objects[$tag]->compile($args, $this, $param1, $param2, $param3);
} |
Original code:
Code: | public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null)
{
// re-use object if already exists
if (!isset($this->_tag_objects[$tag])) {
// lazy load internal compiler plugin
$class_name = 'Smarty_Internal_Compile_' . ucfirst($tag);
if (class_exists($class_name) && (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))) {
$this->_tag_objects[$tag] = new $class_name;
} else {
$this->_tag_objects[$tag] = false;
return false;
}
}
// compile this tag
return $this->_tag_objects[$tag] === false ? false : $this->_tag_objects[$tag]->compile($args, $this, $param1, $param2, $param3);
} |
This modification solves my problem.
I wish my post was useful.
Sorry for my english! |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jul 08, 2015 3:05 am Post subject: |
|
|
The fix is now on Github https://github.com/smarty-php/smarty in the master branch and will later be included in 3.1.28.
Note: you must not overwrite the original $tag variable.
It will be expected in lowercase at other places. |
|
Back to top |
|
jacky256 Smarty n00b
Joined: 07 Jul 2015 Posts: 2
|
Posted: Thu Jul 09, 2015 9:33 pm Post subject: |
|
|
Thanks for quick answer, nice to hear that problem is solved |
|
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
|