Problem/Motivation

If an entity type has no entities, the batch process crashes with:

> An error occurred while processing \Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker with arguments : \Drupal\entity_usage\EntityUsageBatchManager::updateSourcesBatchWorker

although the actual problem is that the entity storage tried to load an entity with id FALSE.

This is because of this:

    $entity_id = reset($entity_ids);

    if (isset($entity_id) && $entity = $entity_storage->load($entity_id)) {

reset([]) is FALSE, so the isset() check is not working as intended.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joachim created an issue. See original summary.

joachim’s picture

Status: Active » Needs review
silvi.addweb’s picture

Status: Needs review » Reviewed & tested by the community

I have tested the MR and it's working fine.

marcoscano made their first commit to this issue’s fork.

  • marcoscano committed 9635b5a3 on 8.x-2.x authored by joachim
    Issue #3444332 by joachim, silvi.addweb, marcoscano: batch process...
marcoscano’s picture

Status: Reviewed & tested by the community » Fixed

Fixed, thanks!

keszthelyi’s picture

I updated entity_usage to 8.x-2.0-beta13 specifically to get the fix for this issue, because I also had the same problem.

The fix worked for the case when the source entity type didn't have any entities, however, I think it also caused a regression, because now entities with ID 0 or '0' are not passing the condition, and craching the batch process (causing an infinite loop). I opened a new issue about it: #3465800

Status: Fixed » Closed (fixed)

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