Commit 6ed1d153 authored by catch's avatar catch
Browse files

Issue #3474692 by longwave, foxtrotcharlie, bbrala: Fix...

Issue #3474692 by longwave, foxtrotcharlie, bbrala: Fix "Twig\Node\Expression\FilterExpression" deprecation introduced in twig/twig 3.12.0

(cherry picked from commit 336ba833)
parent eaa70724
Loading
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -64,13 +64,9 @@
%The "Drupal\\Tests\\Core\\Utility\\MockContainerAware" class implements "Symfony\\Component\\DependencyInjection\\ContainerAwareInterface" that is deprecated since Symfony 6.4, use dependency injection instead.%

# Twig 3.
%Since twig/twig 3.11: Changing the value of a "filter" node in a NodeVisitor class is not supported anymore.%
%Since twig/twig 3.12: Not passing an instance of "TwigFunction" when creating a "attach_library" function of type "Twig\\Node\\Expression\\FunctionExpression" is deprecated.%
%Since twig/twig 3.12: Not passing an instance of "TwigFunction" when creating a "add_component_context" function of type "Twig\\Node\\Expression\\FunctionExpression" is deprecated.%
%Since twig/twig 3.12: Not passing an instance of "TwigFunction" when creating a "render_var" function of type "Twig\\Node\\Expression\\FunctionExpression" is deprecated.%
%Since twig/twig 3.12: Not passing an instance of "TwigFunction" when creating a "validate_component_props" function of type "Twig\\Node\\Expression\\FunctionExpression" is deprecated.%
%Since twig/twig 3.12: Getting node "filter" on a "Twig\\Node\\Expression\\FilterExpression" class is deprecated.%
%Since twig/twig 3.12: Getting node "filter" on a "Twig\\Node\\Expression\\Filter\\DefaultFilter" class is deprecated.%
%Since twig/twig 3.12: Getting node "filter" on a "Twig\\Node\\Expression\\Filter\\RawFilter" class is deprecated.%
%Since twig/twig 3.12: The "tag" constructor argument of the "Drupal\\Core\\Template\\TwigNodeTrans" class is deprecated and ignored%
%Since twig/twig 3.12: Twig Filter "spaceless" is deprecated%
+1 −1
Original line number Diff line number Diff line
@@ -145,7 +145,7 @@ protected function compileString(Node $body) {
          // @see TwigExtension::getFilters()
          $argPrefix = '@';
          while ($args instanceof FilterExpression) {
            switch ($args->getNode('filter')->getAttribute('value')) {
            switch ($args->getAttribute('twig_callable')->getName()) {
              case 'placeholder':
                $argPrefix = '%';
                break;
+2 −2
Original line number Diff line number Diff line
@@ -53,10 +53,10 @@ public function leaveNode(Node $node, Environment $env): ?Node {
    }
    // Change the 'escape' filter to our own 'drupal_escape' filter.
    elseif ($node instanceof FilterExpression) {
      $name = $node->getNode('filter')->getAttribute('value');
      $name = $node->getAttribute('twig_callable')->getName();
      if ('escape' == $name || 'e' == $name) {
        // Use our own escape filter that is MarkupInterface aware.
        $node->getNode('filter')->setAttribute('value', 'drupal_escape');
        $node->setAttribute('twig_callable', $env->getFilter('drupal_escape'));

        // Store that we have a filter active already that knows
        // how to deal with render arrays.