entityRevert breaks config:import if there are entity types that do not have a bundle class

Created on 11 July 2023, over 1 year ago
Updated 14 July 2023, over 1 year ago

Problem/Motivation

The SchedulerManager::entityRevert method seem to expect that the entity type has a bundle class.

For me all config imports are failing with The "" entity type does not exist.. While debugging I found that it's related to the entityRevert method in the scheduler module, that in my case tries to revert the entity type mailchimp_campaign. This entity type has no bundles (and no bundle class).

Therefore it's passing NULL in the following code snippet https://git.drupalcode.org/project/scheduler/-/blob/2.x/src/SchedulerMan...

foreach ($this->entityTypeManager->getStorage($bundleType)->loadMultiple() as $bundle) {

This leads to the exception.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇩🇪Germany szeidler Berlin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @szeidler
  • Status changed to Needs review over 1 year ago
  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    223 pass
  • 🇩🇪Germany szeidler Berlin

    Here's a workaround for the issue that just skips all entity types that do not have bundles.

  • First commit to issue fork.
  • 🇬🇧United Kingdom jonathan1055

    Thanks for reporting this szeidler, and for doing the debugging and providing the precise cause. Just for my info, did you find this problem when upgrading to Scheduler 2.0.0 from 8.x-1.n or have you upgraded from an earlier 2.x version?

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    223 pass
  • @jonathan1055 opened merge request.
  • 🇩🇪Germany szeidler Berlin

    The sites affected, have been based upon Thunder, so went the whole way from 8.x-1.x to 2.0.0

  • 🇬🇧United Kingdom jonathan1055

    Thanks. This was added the most recent commit before 2.0.0 on 🐛 entityRevert breaks config:import if there are entity types that do not have a bundle class Fixed
    I'd be happy to commit this, and then release 2.0.1 as it seems quite a major error.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    223 pass
  • 🇩🇪Germany szeidler Berlin

    I just noticed that it actually is influenced by another pending entity update. So in my use-case there was a pending entity update on that mailchimp_campaign entity type (which has no bundles) and since in Scheduler we retrieve all pending entity updates

    $entityUpdateManager = \Drupal::entityDefinitionUpdateManager();
    $changeList = $entityUpdateManager->getChangeList();
    

    it leads to the error. Means the problem happens

    • On configuration import
    • If an entity type without bundles has pending entity updates

    Since database updates should always run before doing a drush config:import, the problem only occurs if something with the entity update (caused by another module or custom code) went wrong and the error we see here is a side-effect of it.

  • 🇬🇧United Kingdom jonathan1055

    Thanks. This entityRevert function should not have been called during config import, that was an error and I have have removed it in the second commit. The only other places this function is callled are
    (a) via a specific hook update where the parameter of 'paragraph' is passed, which means any other entity with a pending change will be ignored
    (b) In scheduler's own hook_uninstall() ie when Scheduler is being uninstalled
    (c) via drush scheduler:entity-revert

    If you are happy with the change, and it fixes your problem, can you mark this RTBC, then I will commit and release 2.0.1

  • Status changed to RTBC over 1 year ago
  • 🇩🇪Germany szeidler Berlin

    From my side this looks good. Disclaimer: I haven't followed why it was introduced in the first place.

    Even though my issue occurs only, if something else is off (in my case missing/wrong entity updates). This fix will not block any config import in such a scenario. That's good.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    223 pass
  • Status changed to Fixed over 1 year ago
  • 🇬🇧United Kingdom jonathan1055

    Disclaimer: I haven't followed why it was introduced in the first place.

    I rasied the question in #3336108-12: Don't run hook_modules_installed during config install and thought it was wrong to add it during the altered import steps, as it was not part of the original import process. I should have stuck to my hunch and removed it before committing.

    Thanks for RTBC. Merged and fixed.

  • 🇬🇧United Kingdom jonathan1055

    I have now released Scheduler 2.0.1

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024