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
#3104372: Fix Drupal\FunctionalTests\AssertLegacyTrait inconsistent deprecation messages fixed the deprecation test messages for the correct format, while #3031580: Undeprecate \Drupal\FunctionalTests\AssertLegacyTrait and \Drupal\KernelTests\AssertLegacyTrait in Drupal 8 before them made them silent.
Proposed resolution
- replace "Deprecated in" with "@deprecated in" in the class to make the deprecation active again.
- add
@see
to point to a one-stop-shop CR for these deprecations - add
@trigger_error
to code execution - add an entry in the silenced deprecations in DeprecationListener, so the deprecation is not immediately active, but to prepare ground for follow-up issues that will do the proper cleanup assertion method by assertion method
Remaining tasks
Do it once #3104372: Fix Drupal\FunctionalTests\AssertLegacyTrait inconsistent deprecation messages lands.
User interface changes
None.
API changes
None.
Data model changes
None.
Release notes snippet
N/A
Comment | File | Size | Author |
---|---|---|---|
#53 | raw-interdiff-41-48.txt | 1014 bytes | jungle |
#53 | interdiff-48-53.txt | 1020 bytes | jungle |
#53 | 3114617-53.patch | 51.52 KB | jungle |
Comments
Comment #2
Gábor HojtsyComment #3
longwaveDiscussed in Slack, there are also a number of missing trigger_error() calls in these deprecations, so we should add these here if possible.
Comment #4
andypostComment #5
Gábor HojtsyThis is the core of this to replace "Deprecated in" with "@deprecated in". I have no idea which ones should get a trigger_error() and why only some of them have.
Comment #6
Gábor HojtsyActually the @todo should also be removed.
Comment #7
andypostNice!
Comment #8
Gábor HojtsyLet's at least discuss the question of the missing trigger_error()s.
Comment #9
longwaveI don't think these are properly "active" deprecations until trigger_error() is added. I suspect that the reason some of them don't have trigger_error() yet is that core still uses these deprecated methods in non-legacy tests...
Comment #10
andypostthen we have to enforce
trigger_error()
according to deprecation policyComment #11
Gábor HojtsyIn that case we maybe need to turn this into a META and resolve uses in individual issues? Or are there not that many?
Comment #12
andypostGreat idea! While there's not a lot of them
Comment #13
longwaveWe also are supposed to hold off on adding new deprecations until 9.1.x so this might have to be postponed until then.
Comment #14
Gábor HojtsyI think its a release manager question whether this is new or not new :) In #3104372: Fix Drupal\FunctionalTests\AssertLegacyTrait inconsistent deprecation messages @catch was originally saying outright that we should add the @deprecated back into Drupal 8, so its not exactly clear cut.
Comment #15
longwaveAs 9.1.x development is underway I think we can look at this again.
Can we expand the scope of this to cover \Drupal\KernelTests\AssertLegacyTrait as well? The attached patch adds @deprecated notices for that class as well.
Comment #16
longwaveActually let's use the correct syntax, $this instead of self::
Not sure what to do about verbose().
Comment #17
mondrakeParenting. IMHO:
1) this should be the first sub-issue for #3027952: [Plan] Remove the usage of deprecated methods in tests
2) we should make the proper deprecations here, adding the @see to reference CRs, the @trigger_error for the deprecation, and a silencer for the trigger in the DeprecationListener. Later issues will tackle removing the silencers.
Comment #18
longwaveAdded @trigger_error and dummy @see - I can't actually find change records for any of this, so adding the tag for that too.
Comment #20
mondrakeDrafted change record, https://www.drupal.org/node/3129738
Comment #21
mondrakeWorking on deprecation listener.
Comment #22
mondrakeComment #23
longwaveThanks for adding the change record, I updated it to include a table of replacement methods based on the deprecation notices.
A handful of the previous deprecation notices did have links, some to change records and some to issues, but I think it's easier for developers if we put all the information in one place now.
Comment #24
mondrake#23 edited the CR to update about the recommendation to drop calls to
pass
.And yes, one stop shop for all this is helpful :)
Comment #26
mondrakeComment #27
longwaveThis looks good to go to me, but I don't think I can RTBC as I worked on it.
Comment #28
mondrakeI will be bold here, RTBC
It’s not a complicated patch by iteself, no conditional execution, just adding the proper deprecation to methods that needed that long, silencing them while in to be issues the usages (tons of them!) will be finally removed in an orderly manner.
Comment #29
mondrakeComment #30
mondrakeUpdated IS with current proposal
Comment #31
mondrakeNeeds code style fixes
Comment #32
mondrakeOnly changes to CS, Coder is now checking the format of deprecations.
Comment #33
andypostRelated could affect this one, rtbc++
Comment #34
xjmWe're definitely not adding new deprecations to Drupal 8 anymore (we didn't anyway, but definitely not at almost-RC). So untagging RM review. Thanks!
Comment #35
xjmThe diff here and in several other places is just changing the link from the issue to the CR, which is correct. However, that sort of seems like a separate issue scope?
The double-negatives here are confusing. I'd suggest:
(And the same for the
@trigger_error()
, of course.)Thanks!
Comment #36
mondrake#35:
1. IMHO that'd be overkill. I have seen going back and forth with deprecations of this in D8, I'd suggest to make it clear we need to remove those methods by D10, now. This will unleash a lot of work, at least one issue for each of the deprecations, so better have it as soon as we can in 9.1.x
2. Done.
Thanks!
Comment #37
mondrakeI suggest to postpone this on #3114617: Properly deprecate methods in Drupal\FunctionalTests\AssertLegacyTrait and Drupal\KernelTests\AssertLegacyTrait, while still keeping deprecations silenced and on completion of #3128573: [meta] Replace assertions with more appropriate ones, since the sub-issues of #3128573: [meta] Replace assertions with more appropriate ones overlap with the changes here.Comment #38
mondrakeSorry, post to wrong issue in #37.
Comment #39
longwaveReview points addressed, back to RTBC.
Comment #40
xjm#35.1 was not addressed. I'm suggesting to split this patch into two, separating out the different pattern of updating just that one link to a separate issue, which will make it easier to review, commit, and easier get into 9.1.x as you suggest. See https://www.drupal.org/core/scope#context and https://www.drupal.org/core/scope#size for more information. Thanks!
Comment #41
sja112 CreditAttribution: sja112 at Srijan | A Material+ Company for Drupal India Association commented@xjm,
Addressing #35.1. I have updated the patch to remove
and other related changes from the patch.
I will create a separate issue for this change.
Comment #42
sja112 CreditAttribution: sja112 at Srijan | A Material+ Company for Drupal India Association commentedComment #43
sja112 CreditAttribution: sja112 at Srijan | A Material+ Company for Drupal India Association commentedCreated separate issue to track the remaining part of the scope of this issue.
Change the link in @trigger_error and other related palces from the issue to the CR
Comment #44
sja112 CreditAttribution: sja112 at Srijan | A Material+ Company for Drupal India Association commentedComment #45
longwavePersonally I think this was OK to do in the same issue as then it made everything nice and consistent, but as this change has now been made let's get this in and fix the followup issue soon.
@sja112 Thanks for working on this and creating the followup.
Comment #46
xjmNeeds a reroll. Thanks!
Comment #47
sja112 CreditAttribution: sja112 at Srijan | A Material+ Company for Drupal India Association commentedComment #48
sja112 CreditAttribution: sja112 at Srijan | A Material+ Company for Drupal India Association commented@xjm,
I have re-rolled the patch.
Thanks.
Comment #49
sja112 CreditAttribution: sja112 at Srijan | A Material+ Company for Drupal India Association commentedComment #51
jungleOn it
Comment #52
sja112 CreditAttribution: sja112 at Srijan | A Material+ Company for Drupal India Association commentedFailed test not working because of
AssertLegacyTrait::assertHeader() is deprecated in drupal:8.3.0 and is removed from drupal:10.0.0. Use $this->assertSession()->responseHeaderEquals() instead. See https://www.drupal.org/node/3129738
Somehow changing it to drupal:8.2.0 from drupal:8.3.0 in AssertLegacyTrait::assertHeader() --> @trigger_error its working.
Comment #53
jungleThe two versions should be identical. changed 8.3.0 to inline with 8.2.0 in DeprecationListenerTrait
Comment #54
jungleComment #55
longwaveReroll looks good, back to RTBC.
Comment #56
xjmReviewing this one again.
Comment #58
xjmAll right, I tried to read over each deprecation carefully to make sure that the method of names and deprecation's matched. A couple review notes:
This is minor, but it's in enough places (including the test) that I don't feel comfortable fixing it on commit. We don't typically join lists of more than two elements in English with or. It should have commas: "A, B, or C."
It looks like the existing deprecation blocks for the same methods already have this problem, though, so not in scope to fix it here.
These don't have a
@trigger_error()
in the patch. I confirmed in each case that they're already present in the codebase.Same.
Committed to 9.1.x, and published the CR. Thanks!
Comment #59
jungleAdding the "Deprecated assertions" tag to add this into the kanban board https://contribkanban.com/board/Deprecatedassertions
Comment #62
quietone CreditAttribution: quietone as a volunteer commentedClosed #2496109: Replace all usages to deprecated methods on KernelTestBase(NG) as a duplicate, adding credit.