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 | 2024-09-09 08:33 |
Reporter | ckdot | Assigned To | |||
Priority | high | Severity | major | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 6.2.3 | ||||
Target Version | 7.0.1 | Fixed in Version | 7.2.0 | ||
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 | Twig | ||||
Theme | All | ||||
Browser | All | ||||
PHP Version | All | ||||
Database Version | All | ||||
|
-MK |
|
Tested in 7.0.0 Bug still reproducable - mko |
|
Unfortunately still reproduceable in version 7.1.0. The mentioned fix works fine. Please fix it with the next bugfix release. Otherwise it has to be patched with every release. (Bug also reported in 0007552) |