fabpot/Twig — comment on commit 4a91f4ff34f6d704773ca6300758a928394bfe85
File:  line 0
By jmikola:

**Note:** I previously left this comment on 846a2c134d3fc368eb6b9d4b270d5c8eac3eb442, but after stepping through the commits since the v1.3.0 tag, I was able to narrow the change in behavior I experienced down to this commit.

Should this commit have broken BC at all? Per my comment/example in df47659e9de71a48a24f31ed0cc16a2674a06d43, I noticed that Twig is throwing a runtime exception for an undefined key in `Template::getAttribute()` for the following snippet:

{{ user.userProgram.program.branding.bodyLinkColor|default('#0a81bf') }}

As in my other comment, `$user->getProgram()` returns null here.

Based on this commit, it looks like you intended for `|default()` to preserve the compilation `{{ obj is defined ? obj|default('bar') : 'bar' }}`; however, that doesn't agree with what I'm seeing at runtime. Control appears to reach this bit of `Template::getAttribute()`, right down to the `throw` statement:

if (!is_object($object)) {
if ($isDefinedTest) {
return false;
}

if (!$this->env->isStrictVariables()) {
return null;
}

throw new Twig_Error_Runtime(sprintf('Key "%s" for array with keys "%s" does not exist', $item, implode(', ', array_keys($object))));
}