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
| Comment | File | Size | Author |
|---|
Issue fork drupal-3167126
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:
- 3167126-10.1.x
changes, plain diff MR !3769
- 3167126-fix-workspace-overview
changes, plain diff MR !6973
Comments
Comment #2
mheip commentedAdded a patch which checks for the owner and adds fallback to '/' if not available.
Comment #3
amateescu commentedLet's wait for the outcome of #3043725: Provide a Entity Handler for user cancelation, and then we can follow what's being done for other core entity types.
Comment #8
cedricl commentedUpdated patch from #2 for 9.4 support.
Comment #9
smustgrave commentedThe title sounds more like a bug then a support request.
There is no issue summary so that should be added.
This will need steps to reproduce
Test cases
Comment #12
rpayanmTrying to fix the CM Failed.
Comment #13
rpayanmComment #15
ranjith_kumar_k_u commentedAdded tests please review
User interface changes

do we need any meaningful text here instead of "/"?
or empty?
Comment #17
smustgrave commentedThink it should have some default if no user exists.
Not sure if it's possible to know previous user. Or if some other text should work but just "/" is confusing.
Comment #18
ranjith_kumar_k_u commentedAdded text "User not found" instead of "/" and also updated the tests.
Comment #19
smustgrave commentedThink this is a good change.
Comment #21
smustgrave commentedSeems random.
Comment #22
amateescu commentedThe common way to display information that is not known is the string
N/A(stands for not available), let's use that here as well.The whole patch could be shortened to:
'owner' => ($owner = $entity->getOwner()) ? $owner->getDisplayName() : $this->t('N/A'),Comment #25
amateescu commentedApplied the suggestions from #22 and opened a fresh MR.
Comment #26
smustgrave commentedCleaned up patches as fix is in MR.
Test-only was already ran
Main parts of issue summary is there.
Fix came from sub-maintainer so can assume fix is approved.
LGTM!
Comment #27
longwaveBackported to 10.2.x as an eligible bug fix. The "N/A" string is already used in core so no translation issues.
Committed and pushed 0aaa9b8d49 to 11.x and a69343b5b5 to 10.3.x and 099a9c2139 to 10.2.x. Thanks!