-
Notifications
You must be signed in to change notification settings - Fork 711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Key not defined" compile time related issue with sysplugins/smarty_internal_debug.php #674
Comments
Please try #629 and use the Smarty::muteUndefinedOrNullWarnings method. |
I'm testing #629 and I have the following in my template:
Which is generating the following TPL output:
Which results in a |
Using the branch from #629 the follow silenced the above error I mentioned.
It's worth noting that you can also do:
On Smarty 3.x if you just want to get around this on the older smarty until 4.x can be released. It's not an ideal solution, but it works. |
As I said, I do not want to just suppress or mute the warning since I want to see them happen while this is a strong and valid debug mode case of my environment. Smarty should not mute by itself. Also see the other mentioned issue ref (including comments) in my first post. I think this should be fixable. I followed Uwes first fix and saw that in some follow up commits he cleaned up and refactored related things. So I think it has to do with using debugging === 2 and display() or fetch() and could be related to a sub-template usage. (AND/or PHP 8 strict types) I already did some further tests in both render() methods of the After several test sessions i currently came up with adding these !isset return checks /**
* End logging of cache time
*
* @param \Smarty_Internal_Template $template cached template
*/
public function end_template(Smarty_Internal_Template $template)
{
$key = $this->get_key($template);
if (!isset($this->template_data[ $this->index ][ $key ][ 'start_template_time' ])) return;// also see internal_template L 243 and /**
* End logging of compile time
*
* @param \Smarty_Internal_Template $template
*/
public function end_render(Smarty_Internal_Template $template)
{
$key = $this->get_key($template);
if (!isset($this->template_data[ $this->index ][ $key ][ 'start_time' ])) return; // see template_compiled L 119 for the moment. |
I have found a certain use case where
$this->template_data[ $this->index ][ $key ][ 'start_template_time' ]
at L 73 and$this->template_data[ $this->index ][ $key ][ 'start_time' ]
at L 146 'start_...' keys were not defined. (Smarty current)This is caused by using
debugging = true;
in my Smarty class and it does not fail by using{debug}
in a template file otherwise.I couldn't find out yet which specific template call is the root cause for further debugging, since this does not happen everywhere.
Temporarily I put both into a
($foo ?? 0)
PHP 7 ternary, which helps since I do only support up from.So maybe someone can confirm this issue and we can nail it without suppressing the warnings.
(Using PHP 8 in a "personal" debug mode.)
Edit: I found the #266 issue, which is describing the same.
The difference, I do not use {eval} in templates, but there is one $smarty->display('eval:'.$content); around in install cases only, which actually should not interfere here.
The text was updated successfully, but these errors were encountered: