fabpot/Twig — comment on commit 846a2c134d3fc368eb6b9d4b270d5c8eac3eb442
File:  line 0
By jmikola:

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 is definitely reaching this bit of `Template::getAttribute()`:

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))));
}