Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twig the version 1.38.2, breaks the site in drupal #2898

Closed
ldavidsp opened this issue Mar 13, 2019 · 12 comments
Closed

Twig the version 1.38.2, breaks the site in drupal #2898

ldavidsp opened this issue Mar 13, 2019 · 12 comments

Comments

@ldavidsp
Copy link

Twig the version 1.38.2, breaks the site in drupal completely.

image

@Kocal
Copy link
Contributor

Kocal commented Mar 13, 2019

Maybe an error message will help, can you provide one?

@Boegie
Copy link

Boegie commented Mar 14, 2019

I'm experiencing this as well, and I think I've tracked it down to the embed tag.
Templates without it work fine.

The breaking commit seems to be this one: 4eeaf76

The Drupal Error message in its watchdog log is

  | Twig\Error\RuntimeError:  Failed to load Twig template  "[name-of-template].twig",  index "10993019": cache might be corrupted.  __TwigTemplate_6c0bcbf998a75ffe406ad7eb908165951d42a7d9ce59c8eedb0f7b3123e9fbc4___10993019  in Twig\Environment->loadClass() (l
-- | --

@hctom
Copy link

hctom commented Mar 14, 2019

Exactly the same here... also tracked it down to the embed tag. If this is replaced with an include tag, the template is loaded again (for full template path and for namespaced template paths).
For the embed tag neither full template paths nor namespaced template paths work and throw the following exception:

The website encountered an unexpected error. Please try again later.

Twig\Error\RuntimeError</em>: Failed to load Twig template "path/to/user.html.twig", index "1128131273": cache might be corrupted. in Twig\Environment->loadClass() (line 14 of path/to/user.html.twig).

The corresponding template throwing the error has the following code:

{% extends '@my_namespace/partial/content.twig' %}

{% block content_header %}
  {{- title_suffix -}}

  {%- embed '@my_namespace/partial/misc/page-title.twig' %}
    {% block page_title_primary %}
      {{- user.getAccountName() -}}
    {% endblock page_title_primary %}
  {% endembed -%}

  {{- title_prefix -}}
{% endblock content_header %}

{% block content_content %}
  {%- if content %}
    {{- content -}}
  {% endif -%}
{% endblock %}

@timmillwood
Copy link

Which version of Drupal are you using?

It might be worth reporting issues in https://www.drupal.org/project/drupal/issues/3039408

@hctom
Copy link

hctom commented Mar 14, 2019

I use Drupal 8.6.11 and I just created a new issue over there (while also adding a note to the issue linked by @timmillwood): https://www.drupal.org/project/drupal/issues/3040210

@stof
Copy link
Member

stof commented Mar 14, 2019

could it be that you have a cache generated by an older version of Twig ?

@Didel
Copy link

Didel commented Mar 14, 2019

This seems to be a Drupal issue, not a Twig issue. It is however introduced by one of the changes in Twig 1.38. See the related fix for Drupal in https://www.drupal.org/project/drupal/issues/3040210#comment-13022082

@Boegie
Copy link

Boegie commented Mar 14, 2019

Currently we have 3 different people indeed confirming the issue is with Drupal.

@hctom
Copy link

hctom commented Mar 14, 2019

As the issue is getting a lot of traction on drupal.org, it seems that it is bug on that side of the code ;)

Please see https://www.drupal.org/project/drupal/issues/3040210 for a fix and so this issue may be closed

@fabpot fabpot closed this as completed Mar 14, 2019
@xjm
Copy link

xjm commented Mar 14, 2019

So a minor update presumably should not have broken Drupal code, no? Code that hasn't been touched since I think before 8.0.0 broke when we updated to 1.38.2. :)

@Kocal
Copy link
Contributor

Kocal commented Mar 14, 2019

Apparently it brokes because Drupal used some Twig internal code.
Internal code is not covered by semver versioning.

@stof
Copy link
Member

stof commented Mar 14, 2019

Drupal copied some internal code to make its own logic, and this worked only because the logic was the same.
As Twig refactored that internal logic, the Drupal code was not the same than the Twig one anymore, and they got this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

9 participants