Skip to content
Snippets Groups Projects

Issue #3355150: Address LogicExemption being thrown on non-fieldable entities

@@ -8,6 +8,7 @@ use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\FieldableEntityInterface;
use Drupal\Core\Entity\RevisionableStorageInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
@@ -367,14 +368,25 @@ class EntityUsageBatchManager implements LoggerAwareInterface {
*/
public static function doBulkNonRevisionable(EntityStorageInterface $entity_storage, EntityUsageInterface $entity_usage, EntityTypeInterface $entity_type, array &$context): void {
$entity_type_key = $entity_type->getKey('id');
if (!$entity_type_key) {
// There is no ID field, skip processing this entity type.
return;
}
if (empty($context['sandbox']['total'])) {
$id_definition = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($entity_type->id())[$entity_type_key];
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
$entity_field_manager = \Drupal::service('entity_field.manager');
$default_id = '';
if ($entity_type->entityClassImplements(FieldableEntityInterface::class)) {
// Retrieve the ID type from the fieldable entity.
$id_definition = $entity_field_manager->getFieldStorageDefinitions($entity_type->id())[$entity_type_key];
if (($id_definition instanceof FieldStorageDefinitionInterface) && $id_definition->getType() === 'integer') {
$default_id = -1;
}
}
$context['sandbox']['progress'] = 0;
$context['sandbox']['current_id'] = '';
if (($id_definition instanceof FieldStorageDefinitionInterface) && $id_definition->getType() === 'integer') {
$context['sandbox']['current_id'] = -1;
}
$context['sandbox']['current_id'] = $default_id;
$context['sandbox']['entity_ids'] = $entity_storage->getQuery()
->accessCheck(FALSE)
->range(0, static::BULK_ID_LOAD)
Loading