Call to a member function getDisplayname() on null in WorkspaceListBuilder.php

Created on 25 August 2020, about 4 years ago
Updated 25 March 2024, 8 months ago

Problem/Motivation

The following code on the WorkspaceListBuilder.php is causing this problem.
'owner' => $entity->getOwner()->getDisplayName()
There is a chance to get a NULL value from the $entity->getOwner() function when there is no owner

Steps to reproduce

  • Create a workspace with any of the users as owner
  • Delete the user(workspace owner) using the following method "Delete the account and make its content belong to the Anonymous user."
  • Visit workspaces listing page(admin/config/workflow/workspaces)

Proposed resolution

Make sure the value of $entity->getOwner() is not null before calling the getDisplayName() function
eg :

   $owner = $entity->getOwner();
    if ($owner instanceof UserInterface) {
      // code
    }

User interface changes

🐛 Bug report
Status

Fixed

Version

10.2

Component
Workspaces 

Last updated 4 days ago

No maintainer
Created by

🇧🇪Belgium mheip

Live updates comments and jobs are added and updated live.
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.71.5 2024