View Issue Details

IDProjectCategoryView StatusLast Update
0007231OXID eShop (all versions)8. --- Twig engine ---public2023-07-07 16:44
Reporterckdot Assigned To 
PriorityhighSeveritymajorReproducibilityalways
Status confirmedResolutionopen 
Product Version6.2.3 
Target Version7.0.1 
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

QA

2023-07-03 14:53

administrator   ~0015397

Last edited: 2023-07-03 14:54

Tested in 7.0.0
Bug still reproducable
- mko