@@ -455,28 +455,28 @@ public function compileTemplateSource(
455455 $ this ->smarty ->_current_file = $ this ->template ->source ->filepath ;
456456 // get template source
457457 if (!empty ($ this ->template ->source ->components )) {
458- $ _compiled_code = '<?php $_smarty_tpl->_loadInheritance(); $_smarty_tpl->inheritance->init($_smarty_tpl, true); ?> ' ;
459-
460- $ i = 0 ;
461- $ reversed_components = array_reverse ($ this ->template ->getSource ()->components );
462- foreach ($ reversed_components as $ source ) {
463- $ i ++;
464- if ($ i === count ($ reversed_components )) {
465- $ _compiled_code .= '<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl); ?> ' ;
466- }
467- $ _compiled_code .= $ this ->compileTag (
468- 'include ' ,
469- [
470- var_export ($ source ->resource , true ),
471- ['scope ' => 'parent ' ],
472- ]
473- );
474- }
475- $ _compiled_code = $ this ->postFilter ($ _compiled_code , $ this ->template );
458+ $ _compiled_code = '<?php $_smarty_tpl->_loadInheritance(); $_smarty_tpl->inheritance->init($_smarty_tpl, true); ?> ' ;
459+
460+ $ i = 0 ;
461+ $ reversed_components = array_reverse ($ this ->template ->getSource ()->components );
462+ foreach ($ reversed_components as $ source ) {
463+ $ i ++;
464+ if ($ i === count ($ reversed_components )) {
465+ $ _compiled_code .= '<?php $_smarty_tpl->inheritance->endChild($_smarty_tpl); ?> ' ;
466+ }
467+ $ _compiled_code .= $ this ->compileTag (
468+ 'include ' ,
469+ [
470+ var_export ($ source ->resource , true ),
471+ ['scope ' => 'parent ' ],
472+ ]
473+ );
474+ }
475+ $ _compiled_code = $ this ->postFilter ($ _compiled_code , $ this ->template );
476476 } else {
477477 // get template source
478478 $ _content = $ this ->template ->source ->getContent ();
479- $ _compiled_code = $ this ->postFilter ($ this ->doCompile ($ this ->preFilter ($ _content ), true ));
479+ $ _compiled_code = $ this ->postFilter ($ this ->doCompile ($ this ->preFilter ($ _content ), true ));
480480 }
481481 if (!empty ($ this ->required_plugins [ 'compiled ' ]) || !empty ($ this ->required_plugins [ 'nocache ' ])) {
482482 $ _compiled_code = '<?php ' . $ this ->compileRequiredPlugins () . "?> \n" . $ _compiled_code ;
@@ -617,7 +617,8 @@ public function compilePHPFunctionCall($name, $parameter)
617617 {
618618 if (!$ this ->smarty ->security_policy || $ this ->smarty ->security_policy ->isTrustedPhpFunction ($ name , $ this )) {
619619 if (strcasecmp ($ name , 'isset ' ) === 0 || strcasecmp ($ name , 'empty ' ) === 0
620- || strcasecmp ($ name , 'array ' ) === 0 || is_callable ($ name )
620+ || strcasecmp ($ name , 'array ' ) === 0
621+ || (is_callable ($ name ) && !isset ($ this ->smarty ->registered_plugins [Smarty::PLUGIN_MODIFIER ][$ name ]))
621622 ) {
622623 $ func_name = smarty_strtolower_ascii ($ name );
623624
@@ -649,28 +650,42 @@ public function compilePHPFunctionCall($name, $parameter)
649650 }
650651 if ($ func_name === 'empty ' ) {
651652 return $ func_name . '( ' .
652- str_replace ("')->value " , "',null,true,false)->value " , $ parameter [ 0 ]) . ') ' ;
653+ str_replace ("')->value " , "',null,true,false)->value " , $ parameter [0 ]) . ') ' ;
653654 } else {
654- return $ func_name . '( ' . $ parameter [ 0 ] . ') ' ;
655+ return $ func_name . '( ' . $ parameter [0 ] . ') ' ;
655656 }
656657 } else {
657658
658- if (
659- !$ this ->smarty ->loadPlugin ('smarty_modifiercompiler_ ' . $ name )
660- && !isset ($ this ->smarty ->registered_plugins [Smarty::PLUGIN_MODIFIER ][$ name ])
661- && !in_array ($ name , ['time ' , 'join ' , 'is_array ' , 'in_array ' , 'count ' ])
662- ) {
663- trigger_error ('Using unregistered function " ' . $ name . '" in a template is deprecated and will be ' .
664- 'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
665- 'a custom modifier. ' , E_USER_DEPRECATED );
666- }
667-
668- return $ name . '( ' . implode (', ' , $ parameter ) . ') ' ;
659+ if (
660+ !$ this ->smarty ->loadPlugin ('smarty_modifiercompiler_ ' . $ name )
661+ && !isset ($ this ->smarty ->registered_plugins [Smarty::PLUGIN_MODIFIER ][$ name ])
662+ && !in_array ($ name , ['time ' , 'join ' , 'is_array ' , 'in_array ' , 'count ' ])
663+ ) {
664+ trigger_error ('Using unregistered function " ' . $ name . '" in a template is deprecated and will be ' .
665+ 'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
666+ 'a custom modifier. ' , E_USER_DEPRECATED );
667+ }
668+
669+ return $ name . '( ' . implode (', ' , $ parameter ) . ') ' ;
669670 }
670- } else {
671- $ this ->trigger_template_error ("unknown function ' {$ name }' " );
671+
672672 }
673673 }
674+
675+ if (isset ($ this ->smarty ->registered_plugins [Smarty::PLUGIN_MODIFIER ][$ name ])) {
676+ if ($ name === $ this ->smarty ->registered_plugins [Smarty::PLUGIN_MODIFIER ][$ name ][0 ]) {
677+ return $ name . '( ' . implode (', ' , $ parameter ) . ') ' ;
678+ }
679+
680+ return sprintf (
681+ 'call_user_func_array($_smarty_tpl->registered_plugins[ \'%s \' ][ %s ][ 0 ], array( %s )) ' ,
682+ Smarty::PLUGIN_MODIFIER ,
683+ var_export ($ name , true ),
684+ implode (', ' , $ parameter )
685+ );
686+ }
687+
688+ $ this ->trigger_template_error ("unknown function ' {$ name }' " );
674689 }
675690
676691 /**
0 commit comments