EntityReferenceItem::getRandomBundle returns key not value.

Created on 2 May 2018, over 6 years ago
Updated 20 August 2023, over 1 year ago

As party of EntityReferenceItem::generateSampleValue() we may try to create a a sample entity to use for the entity reference field. By looking at the field definition settings we pick a valid bundle at random using EntityReferenceItem::getRandomBundle(). This builds an array of bundles and returns one of them at random. It is supposed to return the bundle string, but incorrectly returns the array key of the bundle array and not the value.

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
FieldΒ  β†’

Last updated 1 day ago

Created by

πŸ‡¬πŸ‡§United Kingdom yanniboi UK

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    As a bug this will need a test case

    Also issue summary should be updated using the default template. Adding proposed solution, remaining tasks, etc.

  • I think the patch will only exacerbate the problem. I've seen custom code and also code in the сore (#1, #2) that also assumes that in target_bundles the key is equal to the bundle ID.

    Perhaps a validation of this configuration is needed, or a way to ensure that the key is a bundle ID?

  • last update over 1 year ago
    30,056 pass
Production build 0.71.5 2024