Steps to reproduce:

Either:

  • Prepare files for a clean install, copy default.services.yml to services.yml
  • Edit services.yml so that twig.config.strict_variables = true
  • Attempt install : works in Drush, not in the UI

Or:

  • Prepare files for a clean install, copy default.services.yml to services.yml
  • Install in Drush or the UI
  • Edit services.yml so that twig.config.strict_variables = true
  • Run drush cr
  • Browse to site: crash because classy uses {{ node_type }} which is undefined. Other undefined variable errors occur if that one is fixed

Enabling strict_variables in Twig is an important element to ensure template quality, much like setting error_reporting to the maximum. Drupal core should not rely on a relaxed setting like strict_variables = false. This is Twig default to ease Twig adoption, but not a good practice when developing.

Comments

Cottser’s picture

Status: Active » Closed (duplicate)
Issue tags: +Twig
Related issues: +#2445705: Core themes should not throw exceptions when strict_variables is TRUE

Thanks for the report @fgm, please direct your attention to #2445705: Core themes should not throw exceptions when strict_variables is TRUE and join the discussion there, or reopen if you disagree that it's a duplicate.

fgm’s picture

@Cottser. It's definitely a duplicate : I wonder why it did not appear when I search the issue queue for strict_variables, though ; but I see it appears now so let keep this one closed and continue on the other one.