Problem/Motivation
The UserSession class has a @todo to make all properties protected. The only remaining one in 11.x is the name property.
This issue makes the name property protected and deprecates calling the function directly. This should cause no BC breaks until the deprecation layer is removed in 12.x
Steps to reproduce
Proposed resolution
Make the name property protected
Add a BC layer with __get & __isset
Remaining tasks
Open MR
Review
Merge
API changes
UserSession::name is now protected.
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3513856
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:
- 3513856-make-usersessionname-protected
changes, plain diff MR !11525
Comments
Comment #3
danielvezaMR is up for this and green. Moving to review.
I imagine this will need a CR?
How would we want to handle the removal of this code in D12? Do we wait for this to be committed and open a follow up?
Comment #4
kim.pepperReviewed this and checked the property can still be accessed and there is a test to trigger the deprecation.
RTBC once we have a CR.
> I imagine this will need a CR?
Yep.
> How would we want to handle the removal of this code in D12? Do we wait for this to be committed and open a follow up?
I think this would get handled when we make deprecation removal issues when 12.x opens up.
Comment #5
danielvezaCR created: https://www.drupal.org/node/3513877
Comment #6
kim.pepperAll good now.
Comment #7
danielvezaFeedback addressed and tests are green again
Comment #8
mstrelan commentedThanks for addressing the isset feedback. I've left one more minor nit but happy to leave at RTBC.
Comment #9
alexpottComment #10
danielvezaAddressed feedback, tests are green
Comment #11
smustgrave commentedSorry but think this missed 11.2, can we update the deprecations for 11.3 please.
What's a recommended way to test this one for when it comes back around.
If you are another contributor eager to jump in, please allow the previous poster(s) at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!
Comment #12
danielvezaUpdated the deprecations to 11.3.
In terms of testing this, there isn't a way to do it via the UI but you can create a PHP script that pretty much follows the test coverage in
testNamePropertyDeprecationand run that withdrush php:scriptSomething like
Comment #13
mstrelan commentedI was thinking the removal might need to be deferred to 13.x as per #3518671: [policy, no patch] Defer disruptive 11.3 deprecations for removal until 13.0 but since
getAccountNamealready exists contrib can still support 11.x and 12.x simultaneously by updating to use the getter.Comment #14
danielvezaDeprecations updated, tests are green
Comment #15
smustgrave commentedThink I agree with @acrambley shouldn't set also be deprecated
Comment #17
riyas_nr commentedDeprecated the set method and added corresponding test coverage. Moving to NR.
Comment #18
smustgrave commentedFeedback appears to be addressed
Comment #19
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #20
smustgrave commentedConflict in core/tests/Drupal/Tests/Core/Session/UserSessionTest.php
Comment #21
smustgrave commentedJK there were some new phpstan failures https://git.drupalcode.org/issue/drupal-3513856/-/jobs/6364907
Comment #22
alexpottCommitted 03b1887 and pushed to 11.x. Thanks!