Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you have the error reporting level of php correctly you can se how it throws the following:
The Twig_Node::getLine method is deprecated since version 1.27 and will be removed in 2.0. Use getTemplateLine() instead.
At vendor/twig/twig/lib/Twig/Node.php
Remove the uses of that method.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2884675-replace-twig-getline-2.patch | 2.19 KB | rodrigoaguilera |
Comments
Comment #2
rodrigoaguileraComment #4
joelpittetWell need to support both likely, not exactly sure how, open to suggestions.
Maybe an override method with the new method calling its parent and statically calling the old method if the new one doesn't exist(spitballed)
Comment #5
joelpittetBy static I mean statically storing the method name to avoid multiple method_exists calls
Comment #7
TR CreditAttribution: TR commentedWhy do we "need to support both"? This is an internal Drupal core usage of a deprecated function in the Twig API. Drupal core does not provide the getLine()/getTemplateLine() functions. Drupal core controls which versions of Twig get distributed with which version of Drupal, so we can fix this deprecated usage for 8.5.x and leave the old usage in 8.4.x.
Fixing this is rather more important now because of how testing is handling deprecation for contrib - turning on test failures for use of deprecated functions immediately broke all the contrib tests in 8.5.x, in part because Core is full of deprecated usages like this.
This use of a deprecated function causes deprecation errors in all my modules and all my functional tests. I don't call this directly, I just use core. And since the testing gives no hint of where the usage occurs, finding all these is real pain. And avoiding things like this is impossible because it's not in my code or even in functions I call from my code - it's way down the stack somewhere in the rendering layer. Core needs to do the right thing here and fix these usages.
Comment #8
TR CreditAttribution: TR commentedOh, and yes, this patch applies cleanly and removes the (unhelpful) deprecated errors that I get when I run my tests:
The Twig_Node::getLine method is deprecated since version 1.27 and will be removed in 2.0. Use getTemplateLine() instead: 146x
(That 146x mean 146 usages of this deprecated function, and all it tells me is that they happened when running my test - I don't get a line number or a call stack or anything.)
Comment #9
joelpittet@TR that's a good point we upgraded past 1.27 already so this can be fixed in 8.5.x and we won't backport it to 8.4.x
This is where we committed an upgrade past 1.27
#2864031: Update twig/twig from v1.25.0 to v1.32.0
Going to run the tests again to ensure they pass.
Comment #10
joelpittetDidn't mean to move the version branch.
Comment #11
joelpittetRTBC++
Thanks @TR
Comment #12
cburschkaSince the update was in 8.4.x and this only changes internal usage, wouldn't it be okay to backport?
Comment #13
catch8.4.x only requires 1.23.1 in composer.json so this isn't backportable, but looks good for 8.5.x
Committed 962122e and pushed to 8.5.x. Thanks!
Comment #15
cburschkaOh - I only looked at the .lock, not the composer.json requirements. Yeah, that makes sense.
Comment #16
catchJust moving back to fixed due to the commit bot crosspost.