loadMultiple with no IDs breaks inside a workspace

Created on 2 February 2023, over 2 years ago

Problem/Motivation

Using loadMultiple without specifying IDs when a workspace is active causes an error in EntityStorageBase::loadMultiple().

This causes a problem if you need to load all entities while a workspace is active. A work-around is to find out every entity ID before, and pass that to loadMultiple.

TypeError: array_diff_key(): Argument #1 ($array) must be of type array, bool given

/var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:302
/var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php:49

This error occurs if no IDs are given because `$flipped_ids` is FALSE, and array_diff_key only works on arrays.

Steps to reproduce

Activate a workspace, then call any loadMultiple function when there is at least one entity of that type in the workspace. Eg, Node::loadMultiple or EntityStorageInterface::loadMultiple.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

10.0

Component
Entity 

Last updated about 17 hours ago

Created by

🇨🇦Canada travis-bradbury

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