symfony/deprecation-contracts/function.php multiple checks

Created on 15 September 2024, 2 months ago
Updated 21 September 2024, about 2 months ago

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

🐛 Bug report
Status

Needs work

Version

4.3

Component

Code

Created by

🇬🇧United Kingdom Jons

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Jons
  • 🇬🇧United Kingdom Jons
  • 🇺🇸United States will_frank

    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.

  • 🇿🇦South Africa foxtrotcharlie

    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.

  • 🇭🇺Hungary Gábor Hojtsy Hungary

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

  • Merge request !101Ignore twig false positives for now → (Merged) created by Gábor Hojtsy
  • Status changed to Needs review about 2 months ago
  • 🇭🇺Hungary Gábor Hojtsy Hungary

    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 :)

  • Status changed to Needs work about 2 months ago
  • 🇭🇺Hungary Gábor Hojtsy Hungary

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

  • First commit to issue fork.
  • Pipeline finished with Failed
    about 2 months ago
    Total: 213s
    #288795
  • Pipeline finished with Failed
    about 2 months ago
    Total: 347s
    #288804
  • Pipeline finished with Failed
    about 2 months ago
    Total: 356s
    #288822
  • Pipeline finished with Failed
    about 2 months ago
    Total: 271s
    #288834
  • Pipeline finished with Failed
    about 2 months ago
    Total: 272s
    #288846
  • Pipeline finished with Failed
    about 2 months ago
    Total: 283s
    #288855
  • 🇭🇺Hungary Gábor Hojtsy Hungary

    The referenced core issue and above that 📌 Fix Twig 3 deprecations Needs review 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.

  • 🇭🇺Hungary Gábor Hojtsy Hungary

    I believe 📌 Twig Filter "spaceless" is deprecated Active is still outstanding but otherwise this is resolved in core and fixes were released in patch versions of core.

  • 🇭🇺Hungary Gábor Hojtsy Hungary

    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.

  • Pipeline finished with Skipped
    29 days ago
    #312598
  • 🇬🇧United Kingdom Jons

    👍

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

Production build 0.71.5 2024