Closed fritzmg closed 6 years ago
{% if sql_message is defined %}
:)
{% if sql_message is defined %} :)
That's not enough. You want to check if sql_message
is defined and not empty in this case - since it could be defined, but empty. hence
{% if sql_message|default %}
Why not add the variable to the default context?
Fixed in cd68833f39bf35f013e067dd49a4649188a19778.
Reproduction
composer create-project contao/managed-edition
.example.org/app_dev.php/contao/install
.On the next step you will see the following error message:
This is because the Twig template
main.html.twig
usesHowever, at this point
sql_message
is a non-existing variable. It would be defined here - but in a fresh installation the function returns here - thus the variable is never defined for the Twig rendering context.Using
is not empty
on non-existent variables will lead to theVariable "…" does not exist
error in the dev environment (it will not yield this error in the prod environment). See also https://straightupcraft.com/articles/testing-if-something-exists-is-defined-length-is-not-null-is-not-emptyYou should use
instead.