-
-
Notifications
You must be signed in to change notification settings - Fork 600
Description
Bug Description
We're super happy users Statamic, but have experienced some weird behavior when working with if conditions in certain situations. We believe it occurs when having more than one "tag" in an if-statement. The tag isn't evaluated to the correct value when using more than one tag in the same if-statement.
I tried to boil it down to a few minimal examples and also did a bit of digging in the source to see the actual PHP output, it seems very likely that it's a bug, or at least some undocumented odd magic that only works in certain situations.
How to Reproduce
See examples below. Seems to happen when you use more than one tag in the same if-statement.
Extra Detail
Example 1
The following:
{{ if collection:handle === "news" || collection:handle === "services" }}
Parsed as correctly as "services" in the first expression, but not the second:
<?php if ('services' === "news" || null === "services"): ?>Example 2
The following does however work for one expression, but not two:
{{ if collection:handle === "news" }}
Parsed correctly as "services"
<?php if ('services' === "news"): ?>Example 3
This doesn't work at all, although this is what I'd expect to work after reading the documentation on "Using tags in conditions"
{{ if {collection:handle} === "news" }}
Parsed as NULL:
<?php if (NULL === "news"): ?>Example 4
Similarly, using two expressions doesn't work:
{{ if {collection:handle} === "news" || {collection:handle} === "services" }}
Parsed as NULL in both places:
<?php if (NULL === "news" || NULL === "services"): ?>Environment
Statamic 3.0.46 Pro
Laravel 6.20.16
PHP 7.4.15
statamic/ssg dev-master
withcandour/aardvark-seo 2.0.9
Starter kit