Problem/Motivation

Running from drush over all modules, a number of modules contain numerous entries as below.

Gin Layout Builder,  1.0.0-rc8
Scanned on Sun, 15/09/2024 - 19:57

FILE: web//var/www/myproject/vendor/symfony/deprecation-contracts/function.php

STATUS         LINE                           MESSAGE                           
--------------------------------------------------------------------------------
Check manually 25   Since twig/twig 3.12: Getting node "filter" on a            
                    "Twig\Node\Expression\FilterExpression" class is deprecated.
--------------------------------------------------------------------------------
Check manually 25   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.    
--------------------------------------------------------------------------------
Check manually 25   Since twig/twig 3.12: Getting node "filter" on a            
                    "Twig\Node\Expression\FilterExpression" class is deprecated.

These don't give the position of the actual error (assuming there is one)
Line 25 of the referenced file is the @trigger line:

    function trigger_deprecation(string $package, string $version, string $message, mixed ...$args): void
    {
        @trigger_error(($package || $version ? "Since $package $version: " : '').($args ? vsprintf($message, $args) : $message), \E_USER_DEPRECATED);
    }

Steps to reproduce

run drush us-a --all > upgrade_status_results.txt

Proposed resolution

Explain position of error such that it can be rectified

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jons created an issue. See original summary.

jons’s picture

Issue summary: View changes
will_frank’s picture

Hoping these comments might help further pin down the problem.

Using the upgrade_status via the UI and running scans
we see the most of these errors for themes, like
Seven 1214 problems
Bootstrap Barrio 1907 problems.
Might the problem have to do with twig code static analysis in particular?

We have updated Drupal Core to 10.3.5 and we noted this following in the
10.3.4 release notes:
The Twig templating library has issued a security advisory. Drupal core is not vulnerable, but previous versions of the drupal/core-recommended package only allowed insecure versions of Twig to be installed. This patch release upgrades Twig to 3.14.0 as a public security hardening.

foxtrotcharlie’s picture

I've also come across this recently when resolving deprecations in custom modules after updating Drupal to 10.3.5. This one in particular was causing over 1800 deprecation warnings in a custom theme:

Since twig/twig 3.12: Getting node "filter" on a "Twig\Node\Expression\FilterExpression" class is deprecated.

My understanding is that this is a bug in Drupal Core, not the custom module, due to the way that core takes over escaping of variables printed in Twig templates, so every variable that is printed is auto escaped, and uses Drupal's custom `drupal_escape` instead of Twig's `escape` filter, which hasn't been updated to resolve the deprecation. This causes every printed variable to trigger this error!

Ideally, one would want upgrade_status to be able to determine whether an error is actually coming from the custom module vs Drupal Core.

gábor hojtsy made their first commit to this issue’s fork.

gábor hojtsy’s picture

Status: Active » Needs review

We also noticed 190k or so of these errors with twig 3.12 across scanning all of contrib with Deprecation Status. Since the error (almost?) always come from core not being compatible, we should not burden users with trying to figure this out. I proposed an MR here that puts the error in the "ignore" category. It is not required to resolve twig 3.12 incompatibilities anyway to be compatible with Drupal 11 :)

gábor hojtsy’s picture

Status: Needs review » Needs work

Uh the tests are also getting caught up with the twig problems, they need to be updated to expect them in an "ignore" category.

bbrala made their first commit to this issue’s fork.

gábor hojtsy’s picture

Status: Needs work » Postponed

The referenced core issue and above that #3473440: [meta] Fix Twig 3 deprecations is where we are actually fixing the core issues that cause this, so Upgrade Status should not fix this for now. The plan is a bugfix release of core soon will fix this. Postponing on that for now.

gábor hojtsy’s picture

I believe #3477375: Provide non-deprecated replacement for Twig "spaceless" filter is still outstanding but otherwise this is resolved in core and fixes were released in patch versions of core.

gábor hojtsy’s picture

Title: symfony/deprecation-contracts/function.php multiple checks » Ignore Twig 3.12 deprecation issues for now
Status: Postponed » Needs review

The tests pass fine on the simple ignore fix now I think given the core fixes. We can merge that in to stop the bleeding on older core versions too without changes needed to the tests.

  • gábor hojtsy committed 7f8ff7c8 on 4.x
    Issue #3474572 by bbrala, gábor hojtsy, jons, foxtrotcharlie, will_frank...
gábor hojtsy’s picture

Status: Needs review » Fixed
jons’s picture

👍

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.