Make UserSession::name protected

Created on 18 March 2025, 4 months ago

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

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component

user.module

Created by

πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

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

Merge Requests

Comments & Activities

  • Issue created by @danielveza
  • Pipeline finished with Failed
    4 months ago
    Total: 106s
    #451678
  • Pipeline finished with Failed
    4 months ago
    Total: 526s
    #451700
  • Pipeline finished with Success
    4 months ago
    Total: 640s
    #451733
  • Pipeline finished with Success
    4 months ago
    Total: 1061s
    #451736
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    MR 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?

  • πŸ‡¦πŸ‡ΊAustralia kim.pepper πŸ„β€β™‚οΈπŸ‡¦πŸ‡ΊSydney, Australia

    Reviewed 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.

  • πŸ‡¦πŸ‡ΊAustralia kim.pepper πŸ„β€β™‚οΈπŸ‡¦πŸ‡ΊSydney, Australia

    All good now.

  • Pipeline finished with Failed
    4 months ago
    Total: 612s
    #453743
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    Feedback addressed and tests are green again

  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    Thanks for addressing the isset feedback. I've left one more minor nit but happy to leave at RTBC.

  • Pipeline finished with Success
    3 months ago
    Total: 603s
    #456729
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ
  • Pipeline finished with Success
    3 months ago
    Total: 634s
    #475468
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    Addressed feedback, tests are green

  • Status changed to Needs work 21 days ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Sorry 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!

  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    Updated 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 testNamePropertyDeprecation and run that with drush php:script

    Something like

    $user = new UserSession([
      'name' => 'test',
    ]);
    // This should throw a deprecation
    echo $user->name;
    echo $user->getAccountName();
    $user->foo = 'test';
    echo $user->foo;
    // This should throw an exception
    echo $user->mail;
  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    I was thinking the removal might need to be deferred to 13.x as per πŸ“Œ Defer disruptive 11.3 deprecations for removal until 13.0 Active but since getAccountName already exists contrib can still support 11.x and 12.x simultaneously by updating to use the getter.

  • Pipeline finished with Success
    20 days ago
    Total: 6865s
    #522990
  • πŸ‡³πŸ‡ΏNew Zealand danielveza Brisbane, AU

    Deprecations updated, tests are green

Production build 0.71.5 2024