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

When append a key to an array in "if condition", an error of level E_NOTICE is generated. #39

Closed
bryceliu opened this issue May 19, 2015 · 1 comment

Comments

@bryceliu
Copy link

Example:

// test.php
require '../libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->debugging = true;
$smarty->caching = true;
$smarty->cache_lifetime = 120;
$smarty->assign('arr', ['first' => 10]);
$smarty->display('test.tpl');

// the template file: test.tpl
{if $arr.second = $arr.first + 100 nocache}
{$arr.first} - {$arr.second}
{/if}

Error as follows:

PHP Notice:  Undefined index: first in /home/bryce/git/smarty/demo/cache/77fd09ff9079054983b57cce4b84650d9500fb25.test.tpl.php on line 32
PHP Stack trace:
PHP   1. {main}() /home/bryce/git/smarty/demo/index.php:0
PHP   2. Smarty->display() /home/bryce/git/smarty/demo/index.php:33
PHP   3. Smarty->fetch() /home/bryce/git/smarty/libs/Smarty.class.php:838
PHP   4. Smarty_Internal_Template->render() /home/bryce/git/smarty/libs/Smarty.class.php:824
PHP   5. Smarty_Internal_Template->getRenderedTemplateCode() /home/bryce/git/smarty/libs/sysplugins/smarty_internal_template.php:275
PHP   6. content_555b17606a6182_39500260() /home/bryce/git/smarty/libs/sysplugins/smarty_internal_template.php:371
PHP Notice:  Undefined index: first in /home/bryce/git/smarty/demo/cache/77fd09ff9079054983b57cce4b84650d9500fb25.test.tpl.php on line 33
PHP Stack trace:
PHP   1. {main}() /home/bryce/git/smarty/demo/index.php:0
PHP   2. Smarty->display() /home/bryce/git/smarty/demo/index.php:33
PHP   3. Smarty->fetch() /home/bryce/git/smarty/libs/Smarty.class.php:838
PHP   4. Smarty_Internal_Template->render() /home/bryce/git/smarty/libs/Smarty.class.php:824
PHP   5. Smarty_Internal_Template->getRenderedTemplateCode() /home/bryce/git/smarty/libs/sysplugins/smarty_internal_template.php:275
PHP   6. content_555b17606a6182_39500260() /home/bryce/git/smarty/libs/sysplugins/smarty_internal_template.php:371
 - 100

Maybe this is not allowed originally.>_<

uwetews added a commit that referenced this issue May 19, 2015
@uwetews
Copy link
Contributor

uwetews commented May 19, 2015

This notice should have popped up just once when the modified template got recompiled.

The patch is now in dev-master. It will be included in 3.1.24 which will be released very soon.

@uwetews uwetews closed this as completed May 19, 2015
think-mcunanan pushed a commit to think-mcunanan/smarty that referenced this issue Mar 22, 2023
Merge release-2.0.4 release branch into master
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