EntityStorageInterface::loadMultiple() should document that invalid IDs are not present in the return array

Created on 30 October 2024, 22 days ago

Problem/Motivation

EntityStorageInterface::loadMultiple() doesn't document what happens if some IDs are invalid, for example:

$entities = $storage->loadMultiple(1, 999999999999);

Will there be a 999999999999 key in the return array or not? If there is, what is its value?

Looking at core's implementation in EntityStorageBase, we can see the answer is that it won't be there:

    if ($flipped_ids) {
      // Remove any invalid IDs from the array and preserve the order passed in.
      $flipped_ids = array_intersect_key($flipped_ids, $entities);
      $entities = array_replace($flipped_ids, $entities);
    }

Steps to reproduce

Proposed resolution

Document that invalid IDs are not returned in the interface.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component

documentation

Created by

πŸ‡¬πŸ‡§United Kingdom joachim

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024