Drupal gdpr_tasks module error when rendering task list row

Note Statistics

Note Statistics

  • Viewed 47 times
Mon, 05/03/2021 - 21:11

GDPR Module version : 2.0.0-alpha7

One of the reason when getting the error below

Error: Call to a member function toLink() on null in Drupal\gdpr_tasks\TaskListBuilder->buildRow() 

is because the user in question might be deleted. The code assumes that the user exists and does not check for null before getting user data

change this line

$row['user'] = $entity->getOwner()->toLink()->toString();


$row['user'] = $entity->getOwner() != null ? $entity->getOwner()->toLink()->toString() : 'Deleted User';

and this line

$row['requested_by'] = $entity->requested_by->entity->toLink()->toString();


$row['requested_by'] = $entity->requested_by->entity != null ? $entity->requested_by->entity->toLink()->toString()  : 'Deleted User';

Or even better create a patch that you can apply after installing the module.

Authored by