Problem/Motivation

Quoting @alexpott from #3041076-44: Update Drupal 9 to Twig 2:

There's not much we can do about the The "Twig\Environment::getTemplateClass()" method is considered internal. It may change without further notice. You should not extend it from "Drupal\Core\Template\TwigEnvironment". over than remove \Drupal\Core\Template\TwigEnvironment::getTemplateClass() which exists for performance reasons. I guess we could try to get the perf improvement upstream.

#1979290: Add static caching to Twig_Environment::getTemplateClass() overrode \Drupal\Core\Template\TwigEnvironment::getTemplateClass() as a performance improvement.

Then @Cottser pointed out in #3041076-47: Update Drupal 9 to Twig 2:

Regarding getTemplateClass please see this old upstream issue: https://github.com/twigphp/Twig/pull/1071

Followed by @alexpott in #3041076-48: Update Drupal 9 to Twig 2:

So upstream tried this and it broke stuff - that's useful info. I don't know how we're going to solve the The "Twig\Environment::getTemplateClass()" method is considered internal. It may change without further notice. You should not extend it from "Drupal\Core\Template\TwigEnvironment". deprecation. But I'm not sure that that matters for getting Twig2 done. Maybe I'll try a PR to remove the @internal or add a flag to enable this caching.

Proposed resolution

TBD

Remaining tasks

Investigate how we can add an upstream feature that allows us to remove this Drupal-specific performance optimization

User interface changes

None.

API changes

TBD

Data model changes

None.

Release notes snippet

TBD

Comments

Wim Leers created an issue. See original summary.

wim leers’s picture

Title: Refactor \Drupal\Core\Template\TwigEnvironment::getTemplateClass() away, contribute it upstream, » Investigate \Drupal\Core\Template\TwigEnvironment::getTemplateClass(): check if it still provides value, and if so, contribute it upstream

Wim Leers credited Cottser.

wim leers’s picture

Issue summary: View changes

Oh, cool, upstream already tried this and it broke. Updating issue summary.

Also crediting @alexpott & @Cottser.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.