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.
Problem/Motivation
Libraries can be deprecated, but we don't tell themes that are overriding or extending existing libraries that they need to update (only users of the library itself). If a theme only overrides, it might never see the deprecation error if the library is unused.
Follow-up from #3113400: Deprecate more jQuery UI library definitions
Steps to reproduce
Proposed resolution
When a library being overridden or extended is deprecated, trigger a deprecation error.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#24 | interdiff-22-24.txt | 1021 bytes | jungle |
#24 | 3163500-24.patch | 19.32 KB | jungle |
Comments
Comment #2
JeroenTComment #3
catchComment #4
catchFollowing lauriii's review of #3113400: Deprecate more jQuery UI library definitions let's make this a pre-requisite rather than a follow-up.
Comment #5
nod_Comment #6
jungleComment #7
lauriiiAdded some tests and adjusted the deprecation messages to display the change record.
Comment #8
lauriiiWhile I was working on this, I opened #3166553: Move libraries-extend and libraries-override processing to a more logical class too to make the processing easier to understand and more logical.
Comment #10
lauriiiMoving back to NR since the fails are in the test only patch
Comment #11
longwaveLooks pretty good so far!
Nice, I like how this is similar to service deprecation in Symfony.
Is
sprintf('%s %s')
really necessary, we can just use concatenation?Typo in "deprecations"
Comment #12
lauriiiThanks for the review @longwave!
#11.2 I don't have a strong preference on to which approach we should use. I changed this to double quotes but I'm fine with concatenation too.
#11.3 Fixed
Comment #13
jungleFixing 12 CS violations further.
Comment #14
longwaveWhy do we need the error handler dance in the test, can't we use the @expectedDeprecation tag?
Similar here, we have ExpectDeprecationTrait to use in unit tests.
Comment #15
lauriiiBoth,
Symfony\Bridge\PhpUnit\ExpectDeprecationTrait
and@expectedDeprecation
requires adding the test to the@group legacy
. I'm not sure we want that here because we are not testing deprecated code but our own APIs that allow deprecating code. Similar approach was taken in #3064017: Create a means to mark an asset library as deprecated in a *.libraries.yml file.Comment #16
longwaveHm, we have lots of tests that test deprecation implementations, that do use @group legacy with @expectedDeprecation, some examples:
I wonder if we need a new @group that will let us test things like this without implying they are actually going to be removed.
Comment #17
catchA wide definition of @legacy would include APIs for deprecating other code, although yeah being able to distinguish between the two would be good. I do think we should probably use @legacy for now since the functionality it provides is fine.
Comment #18
lauriiiThis implements the tests using @expectedDeprecation ✌️
Comment #19
larowlanThis looks great, just a couple of minor items
this shouldn't be in the patch, might be worth adding to your .git/info/exclude
Should we be using class constants for new code?
Comment #20
raman.b CreditAttribution: raman.b at OpenSense Labs commentedComment #21
longwaveI know this is just test code but I realised the version numbers make no sense, we deprecate it after we remove it. In the other test case we say "is removed from drupal:10.0.0".
Out of scope for here but to avoid confusing test deprecations with real deprecations should we use fake version numbers like X.0.0 and Y.0.0 in tests?
Comment #22
jungle+1 to use fake version numbers and updated the patch accordingly.
Comment #24
jungleOne usage missied
Comment #25
longwaveHmm, I thought changing this might need a policy discussion as we haven't done it anywhere else yet. But as you agree, let's be bold and mark RTBC and see what core committers think. Otherwise the patch is good, this was just a last-minute nit.
Comment #26
catch+1 to the fake version numbers, means this won't look out of date every two years. Will try to give this a more in-depth review asap (but not likely this afternoon).
Comment #28
catchOK so the only issue here is that @expectedDeprecation is itself deprecated per #3172438: Since symfony/phpunit-bridge 5.1: Using "@expectedDeprecation" annotations in tests is deprecated, use the "ExpectDeprecationTrait::expectDeprecation()" method instead., but I think it's OK to defer changing how we test deprecations to that issue.
Committed 07daa79 and pushed to 9.1.x. Thanks!
This issue doesn't need its own change record, but I added it to https://www.drupal.org/node/3064022 for background.