{"action":"closed","issue":{"url":"https://api.github.com/repos/smarty-php/smarty/issues/347","repository_url":"https://api.github.com/repos/smarty-php/smarty","labels_url":"https://api.github.com/repos/smarty-php/smarty/issues/347/labels{/name}","comments_url":"https://api.github.com/repos/smarty-php/smarty/issues/347/comments","events_url":"https://api.github.com/repos/smarty-php/smarty/issues/347/events","html_url":"https://github.com/smarty-php/smarty/issues/347","id":215372271,"number":347,"title":"3.1.31 potentially breaks if statement order","user":{"login":"eth8505","id":1136509,"avatar_url":"https://avatars2.githubusercontent.com/u/1136509?v=3","gravatar_id":"","url":"https://api.github.com/users/eth8505","html_url":"https://github.com/eth8505","followers_url":"https://api.github.com/users/eth8505/followers","following_url":"https://api.github.com/users/eth8505/following{/other_user}","gists_url":"https://api.github.com/users/eth8505/gists{/gist_id}","starred_url":"https://api.github.com/users/eth8505/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eth8505/subscriptions","organizations_url":"https://api.github.com/users/eth8505/orgs","repos_url":"https://api.github.com/users/eth8505/repos","events_url":"https://api.github.com/users/eth8505/events{/privacy}","received_events_url":"https://api.github.com/users/eth8505/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-03-20T09:59:07Z","updated_at":"2017-04-17T02:37:10Z","closed_at":"2017-04-17T02:37:10Z","body":"As described on the forums here: http://www.smarty.net/forums/viewtopic.php?p=92056#92056 the bugfix applied here https://github.com/smarty-php/smarty/commit/b8acd7ea176bee219f65eed15721dbd23b3c24ed potentially breaks the processing order of if statements.\r\n\r\nLet me re-describe:\r\n\r\nAssuming I have a class with a has($key) and a get($key) method, where the get() method throws an exception if $key does not exist in the internal stack. If I then build the following if statement with smarty, the get() exception will be triggered with 3.1.31, but not with 3.1.30 or 3.1.29.\r\n\r\n```\r\n{if !$stack->has('mykey') || empty($stack->get('mykey')}\r\n{/if}\r\n```\r\n\r\nThe variable prefixing done by the php function parser for empty() function calls will convert the statement into\r\n```\r\n<?php $_prefixVariable1=$_smarty_tpl->tpl_vars['stack']->value->get('mykey');\r\nif ($_smarty_tpl->tpl_vars['element_current']->value->has('mykey') && !empty($_prefixVariable1)) {?>\r\n```\r\n\r\nWhich totally breaks the original handling of if statements, as the empty() call would never have to be executed if the key does not exist."}}
{"actor":{"display_login":"uwetews"}}