Use chaining for User::addRole() and ::removeRole()

Created on 5 January 2023, over 1 year ago
Updated 20 June 2024, 22 days ago

Problem/Motivation

This is a follow up to User::addRole() and ::removeRole() should be chainable Fixed .

Now that User::addRole() and ::removeRole() are chainable, the usages in core can be changed.

Steps to reproduce

Proposed resolution

Find usages of User::addRole() and ::removeRole() and change the code to be chained.
For example, convert

    $user1->addRole('administrator');
    $user1->activate();
    $user1->setLastAccessTime($request_time);
    $user1->save();

to

    $user1->addRole('administrator')
      ->activate()
      ->setLastAccessTime($request_time)
      ->save();

Remaining tasks

Patch
Review
Commit

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Fixed

Version

10.3

Component
User system 

Last updated about 13 hours ago

Created by

🇳🇿New Zealand quietone New Zealand

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024