View Issue Details

IDProjectCategoryView StatusLast Update
0007231OXID eShop (all versions)8. --- Twig engine ---public2021-04-23 09:31
Reporterckdot 
PriorityhighSeveritymajorReproducibilityalways
Status acknowledgedResolutionopen 
Product Version6.2.3 
Target VersionFixed in Version 
Summary0007231: ifcontent will parse body even if content not existing
DescriptionSee 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('}');
TagsNo tags attached.
ThemeAll
BrowserAll
PHP VersionAll
Database VersionAll

Activities

QA

2021-04-23 09:31

administrator   ~0013429

-MK