smarty icon indicating copy to clipboard operation
smarty copied to clipboard

Smarty 4.5.2 template generation causes PHP Warning: Array to string conversion error

Open jmd8045 opened this issue 1 year ago • 1 comments

PHP 8.2

$utility_links = array( 0 => array('name'     => 'Member Login',
                                          'hrefpage' => 'login_page.php'));

TEMPLATE: SMARTY 4.5.2

{section name="i" loop=$utility_links}
        <a href="{$utility_links[i].hrefpage}"> {$utility_links[i].name} </a> |
{/section}

This has been working fine previously, but since conversion to Smarty 4.5.2 I get: Array to string conversion in /var/www/members.austintgca.com/htdocs/smarty/templates_c/1ca2fef31b64289057db4688371cb3bf741c93cd_0.file.static_main_page.tpl.php on line 35

I have just about beat the old noggin to death but I don't see the error: From TEMPLATE GENERATED LINE 35

$_smarty_tpl->_subTemplateRender("file:utility_links_nav.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, $_smarty_tpl->cache_lifetime, array('utility_links'=>((string)$_smarty_tpl->tpl_vars['utility_links']->value)), 0, false);

Do you think this is a scope error?

Origin: "Smarty object"	
Value
"TGCA - Management System"	
$section_current_member
Origin: "Smarty object"	
Value
" "	
$section_name
Origin: "Smarty object"	
Value
"Sub Menu"	
$sessionid
Origin: "Smarty object"	
Value
"5434647"	
$style_sheet
Origin: "Smarty object"	
Value
"http://jmdlocaltest/../css/emx_nav_left.css"	
$tgca_version
Origin: "Smarty object"	
Value
"PROD_16_07"	
$title
Origin: "Smarty object"	
Value
""	
$utility_links
Origin: "file:utility_links_nav.tpl"	
Value
"Array"	
$ver
Origin: "Smarty object"	
Value
"?v=PROD_16_07"

jmd8045 avatar Apr 18 '24 11:04 jmd8045

The code you present does not compile into a _subTemplateRender call. Can you provide a reproduction scenario that triggers this error?

wisskid avatar Apr 19 '24 09:04 wisskid

Closed because of inactivity.

wisskid avatar Aug 28 '24 22:08 wisskid