Skip to content
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

bug? Creating default object from empty value #238

Closed
ophian opened this issue Jun 7, 2016 · 3 comments
Closed

bug? Creating default object from empty value #238

ophian opened this issue Jun 7, 2016 · 3 comments

Comments

@ophian
Copy link

ophian commented Jun 7, 2016

Smarty version 3.1.30-dev/72
(That was definitely working prior to some of the latest commits, Uwe.)

Fatal error: Uncaught exception 'ErrorException' with message 'Warning: Creating default object from empty value' in [... tpl files]\*_1.file.show_plugins.fnc.tpl.php:50 Stack trace: #0 [... tpl files]*_1.file.show_plugins.fnc.tpl.php(50): errorToExceptionHandler(2, 'Creating defaul...', '[... path]', 50, Array) #1 [... libs]\Smarty\libs\sysplugins\smarty_template_resource_base.php(128): content_5756722242d301_28010074(Object(Smarty_Internal_Template)) #2 [... libs]\Smarty\libs\sysplugins\smarty_template_compiled.php(162): Smarty_Template_Resource_Base->getRenderedTemplateCode(Object(Smarty_Internal_Template)) #3 [... libs]\Smarty\libs\sysplugins\smarty_internal_te in

Sadly (#3)-trace breaks here, while path strings were too long, I assume.

Edit: line 50 in the compiled file is $_smarty_tpl->tpl_vars['plugin_data']->index = -1;
Edit2: temporary disable this line `#$_smarty_tpl->tpl_vars['plugin_data']->index = -1; helps!

Thanks, @uwetews

@ophian
Copy link
Author

ophian commented Jun 9, 2016

@uwetews I just saw another bug report in issue #239.
I think that this might be related to what I have caught, but in difference I need to add here, that my (sub)array is not empty. It has named keys.

Edit: I recognized it is an empty array as well, looping in the first run, which we catch with {if !is_array($array)}.

@ophian
Copy link
Author

ophian commented Jul 6, 2016

temporary fixed with

@@ -209,14 +209,14 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
             $output .= "{$itemVar}->show = ({$itemVar}->total > 0);\n";
         }
         if (isset($itemAttr[ 'iteration' ])) {
             $output .= "{$itemVar}->iteration = 0;\n";
         }
+        $output .= "if (\$_from !== null) {\n";
         if (isset($itemAttr[ 'index' ])) {
             $output .= "{$itemVar}->index = -1;\n";
         }
-        $output .= "if (\$_from !== null) {\n";
         $output .= "foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
         if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
             $output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
         }
         if (isset($itemAttr[ 'iteration' ])) {

@uwetews
Copy link
Contributor

uwetews commented Jul 11, 2016

The fix is now in the master branch

@uwetews uwetews closed this as completed Jul 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants