Don't trust original is present

Created on 28 May 2024, 8 months ago
Updated 11 June 2024, 7 months ago

Problem/Motivation

Error: Call to a member function getUserId() on null Trace: #0 [internal function]: registration_entity_presave(Object(Drupal\registration\Entity\Registration))

This must be caused by $entity->original not reliably being set in some weird circumstance:

function registration_entity_presave(EntityInterface $entity) {
   ...
  if ($entity instanceof RegistrationInterface) {
    ...
    // If the registration user was updated, clear cache tags for the old user.
    if (!$entity->isNew() && ($entity->getUserId() != $entity->original->getUserId())) {

Steps to reproduce

Not sure. I found this because of detailed logging, but I don't understand the root cause.

Proposed resolution

Check $entity->original is set. This is what we do everywhere else when working with original.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

3.1

Component

Registration Core

Created by

πŸ‡¬πŸ‡§United Kingdom jonathanshaw Stroud, UK

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024