@@ -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 ;
@@ -618,8 +618,7 @@ public function compilePHPFunctionCall($name, $parameter)
618618 if (!$ this ->smarty ->security_policy || $ this ->smarty ->security_policy ->isTrustedPhpFunction ($ name , $ this )) {
619619 if (strcasecmp ($ name , 'isset ' ) === 0 || strcasecmp ($ name , 'empty ' ) === 0
620620 || strcasecmp ($ name , 'array ' ) === 0
621- || is_callable ($ name )
622- || isset ($ this ->smarty ->registered_plugins [Smarty::PLUGIN_MODIFIER ][$ name ])
621+ || (is_callable ($ name ) && !isset ($ this ->smarty ->registered_plugins [Smarty::PLUGIN_MODIFIER ][$ name ]))
623622 ) {
624623 $ func_name = smarty_strtolower_ascii ($ name );
625624
@@ -651,37 +650,42 @@ public function compilePHPFunctionCall($name, $parameter)
651650 }
652651 if ($ func_name === 'empty ' ) {
653652 return $ func_name . '( ' .
654- str_replace ("')->value " , "',null,true,false)->value " , $ parameter [ 0 ]) . ') ' ;
653+ str_replace ("')->value " , "',null,true,false)->value " , $ parameter [0 ]) . ') ' ;
655654 } else {
656- return $ func_name . '( ' . $ parameter [ 0 ] . ') ' ;
655+ return $ func_name . '( ' . $ parameter [0 ] . ') ' ;
657656 }
658657 } else {
659658
660- if (
661- !$ this ->smarty ->loadPlugin ('smarty_modifiercompiler_ ' . $ name )
662- && !isset ($ this ->smarty ->registered_plugins [Smarty::PLUGIN_MODIFIER ][$ name ])
663- && !in_array ($ name , ['time ' , 'join ' , 'is_array ' , 'in_array ' , 'count ' ])
664- ) {
665- trigger_error ('Using unregistered function " ' . $ name . '" in a template is deprecated and will be ' .
666- 'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
667- 'a custom modifier. ' , E_USER_DEPRECATED );
668- }
669-
670- if (isset ($ this ->smarty ->registered_plugins [Smarty::PLUGIN_MODIFIER ][$ name ][0 ])
671- && !is_string ($ this ->smarty ->registered_plugins [Smarty::PLUGIN_MODIFIER ][$ name ][0 ])) {
672- return sprintf (
673- 'call_user_func_array($_smarty_tpl->registered_plugins[ \'%s \' ][ %s ][ 0 ], array( %s )) ' ,
674- Smarty::PLUGIN_MODIFIER ,
675- var_export ($ name , true ),
676- implode (', ' , $ parameter )
677- );
678- }
679- 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 ) . ') ' ;
680670 }
681- } else {
682- $ this ->trigger_template_error ("unknown function ' {$ name }' " );
671+
683672 }
684673 }
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 }' " );
685689 }
686690
687691 /**
0 commit comments