-
Notifications
You must be signed in to change notification settings - Fork 641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.x]: Attribute defined test on Component classes always returns true
#14934
Comments
true
true
My memory is that I just tested on 4.8.9 (last release before 0e31c67) and even 4.7.4 (last release before updating Twig from 3.4 to 3.8 via aa6fe4e), and in both cases I’m getting the same |
So I did a deep dive on this a while ago to figure out what was going on... {% if craft.mattwilcox is defined %}
<p>Hi, Matt!</p>
{% endif %} compiles down to this PHP: // line 18
if (craft\helpers\Template::attribute($this->env, $this->source, ($context["craft"] ?? null), "mattwilcox", [], "any", true, true)) {
// line 19
echo " <p>Hi, Matt!</p> which ends up calling TL;DR: because the |
Right… it’s a byproduct of Twig trying to be extremely lenient on method syntax, e.g. if you type I feel like the only time |
Description
The attribute
is defined
test on objects that extend theComponent
class (or any class that implements__call()
) always returnstrue
.Possibly caused by the changes introduced by @brandonkelly in 0e31c67.
Steps to reproduce
Expected behavior
It should output
Method does not exist
.Actual behavior
It outputs
Method exists
.Craft CMS version
5.1.0
PHP version
No response
Operating system and version
No response
Database type and version
No response
Image driver and version
No response
Installed plugins and versions
No response
The text was updated successfully, but these errors were encountered: