View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0007231 | OXID eShop (all versions) | 8. --- Twig engine --- | public | 2021-04-22 11:19 | 2023-07-07 16:44 |
Reporter | ckdot | ||||
Priority | high | Severity | major | Reproducibility | always |
Status | confirmed | Resolution | open | ||
Product Version | 6.2.3 | ||||
Target Version | Patch for 7.0 | Fixed in Version | |||
Summary | 0007231: ifcontent will parse body even if content not existing | ||||
Description | See this smarty code: [{oxifcontent ident="mycontenttemplate" object="oCont"}] foobar [{/oxifcontent}] -> foobar will not be displayed if mycontenttemplate does not exist, so oCont is false See this twig code: {% ifcontent ident "mycontenttemplate" set oCont %} foobar {% endifcontent %} -> foobar will be displayed even if oCont is false why is that? because you didn't add a condition before compiling the body in \OxidEsales\Twig\Node\IfContentNode::compile quick fix: replace $compiler ->subcompile($this->getNode('body')) ->write("unset(")->subcompile($this->getNode('variable'))->raw(");\n");; with: $compiler ->raw('if (') ->subcompile($this->getNode('variable')) ->raw(' !== false) {') ->subcompile($this->getNode('body')) ->write("unset(")->subcompile($this->getNode('variable'))->raw(");\n") ->raw('}'); | ||||
Tags | No tags attached. | ||||
Theme | All | ||||
Browser | All | ||||
PHP Version | All | ||||
Database Version | All | ||||