checks for bundle entity classes should happen in rebuild, not runtime

Created on 31 January 2022, almost 3 years ago
Updated 23 August 2024, 4 months ago

Problem/Motivation

ContentEntityStorageBase::getEntityClass() checks to see if a bundle class is correctly defined as a child class of the entity class.

However, this check should happen during a rebuild, rather than when an entity is being loaded.

The current check won't happen until an entity of that type and bundle is loaded, which means an error might not be noticed.

Checking on rebuild means a developer is made aware of a problem much sooner.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Entity 

Last updated about 17 hours ago

Created by

🇬🇧United Kingdom joachim

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.

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.

  • 🇺🇸United States smustgrave

    Doesn't seem like a novice level issue so removing that tag.

  • 🇬🇧United Kingdom joachim

    Fixed the two comments on the MR.

    However, there is another problem:

              if ($bundle_entity_type = $entity_type->getBundleEntityType()) {
                foreach ($this->entityTypeManager->getStorage($bundle_entity_type)->loadMultiple() as $entity) {
    

    Bundles are not necessarily entities! Modules can use hook_entity_bundle_info() to define bundles for an entity type, without using a config entity to define them.

    The code is currently only handling the bundle entity case, and not handling code-defined bundles at all.

    Fix coming.

  • Pipeline finished with Failed
    5 months ago
    Total: 156s
    #252539
  • Status changed to Needs review 5 months ago
  • 🇬🇧United Kingdom joachim

    Updated the tests.

    This is ready but MR needs repointing.

  • Pipeline finished with Failed
    5 months ago
    Total: 196s
    #252570
  • Status changed to Needs work 4 months ago
  • 🇺🇸United States smustgrave

    Believe the MR needs to be updated to 11.x

  • Status changed to Needs review 4 months ago
  • 🇬🇧United Kingdom joachim
  • Pipeline finished with Canceled
    4 months ago
    Total: 127s
    #262840
  • Pipeline finished with Failed
    4 months ago
    #262842
  • Status changed to Needs work 4 months ago
  • 🇺🇸United States smustgrave

    Fixed the phpcs issue but appears to have test failures.

Production build 0.71.5 2024