Problem/Motivation

Group 4.0.0-alpha2 and 4.0.x declare core_version_requirement: ^11.4 || ^12, but still read the magic $entity->original property. Drupal 11.2 replaced it with getOriginal() / setOriginal(), and Drupal 12 removed the property (change record).

On Drupal 12.0.0-beta2, saving any existing user fails:

Error: Call to a member function getRoles() on null in Drupal\group\Hook\UserHooks->userUpdate()

The same pattern is in Group::preSaveRevision() (revision log message is no longer preserved) and GroupRelationship::postSave() (group role cache rebuild check is skipped). Rector and the automated D12 issue don't catch these because the property is magic.

Steps to reproduce

  1. Install Drupal 12.0.0-beta2 with Group 4.0.x.
  2. Edit and save any existing user.

Proposed resolution

Use getOriginal() in all three places. It's safe because Group 4 already requires Drupal 11.4+. Also type-hint UserHooks::userUpdate() with UserInterface, since getOriginal() isn't on AccountInterface.

Remaining tasks

Review the MR.

Issue fork group-3631301

Command icon 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:

Comments

ivrh created an issue. See original summary.

ivrh’s picture

Status: Active » Needs review

MR !342 replaces the three remaining ->original reads with getOriginal(). With it applied, user saves work again on Drupal 12.0.0-beta2.