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
Comments
Comment #3
joachim commentedComment #4
silvi.addweb commentedI have tested the MR and it's working fine.
Comment #7
marcoscanoFixed, thanks!
Comment #8
keszthelyi commentedI 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