diff --git a/core/modules/system/src/Form/PrepareModulesEntityUninstallForm.php b/core/modules/system/src/Form/PrepareModulesEntityUninstallForm.php index 1b82ea7..07b783d 100644 --- a/core/modules/system/src/Form/PrepareModulesEntityUninstallForm.php +++ b/core/modules/system/src/Form/PrepareModulesEntityUninstallForm.php @@ -205,11 +205,13 @@ public static function deleteContentEntities($entity_type_id, $limit, &$context) if ($entities = $storage->loadMultiple($entity_ids)) { $storage->delete($entities); } - $context['sandbox']['progress'] += count($entity_ids); + // Sometimes deletes cause secondary deletes. For example, deleting a + // taxonomy term can cause it's children to be be deleted too. + $context['sandbox']['progress'] = $context['sandbox']['max'] - $storage->getQuery()->count()->execute(); // Inform the batch engine that we are not finished and provide an // estimation of the completion level we reached. - if ($context['sandbox']['progress'] != $context['sandbox']['max']) { + if (count($entity_ids) > 0 && $context['sandbox']['progress'] != $context['sandbox']['max']) { $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; $context['message'] = t('Deleting items... Completed @percentage% (@current of @total).', ['@percentage' => round(100 * $context['sandbox']['progress'] / $context['sandbox']['max']), '@current' => $context['sandbox']['progress'], '@total' => $context['sandbox']['max']]);