Fix for #2925 and #4290 (Twig does not properly support null attribute and relationship values)