diff --git a/src/Entity/EntitySubqueue.php b/src/Entity/EntitySubqueue.php index 773f58f3b0ad3268ada5784b4aabf8bfbfa32fd9..932a926c6697ca4204a2eb64013b963f5390a4a1 100644 --- a/src/Entity/EntitySubqueue.php +++ b/src/Entity/EntitySubqueue.php @@ -331,7 +331,7 @@ class EntitySubqueue extends EditorialContentEntityBase implements EntitySubqueu public function getItemPosition(EntityInterface $entity) { $subqueue_items = $this->get('items')->getValue(); $subqueue_items_ids = array_map(function ($item) { - return $item['target_id']; + return $item['target_id'] ?? NULL; }, $subqueue_items); return array_search($entity->id(), $subqueue_items_ids); diff --git a/tests/src/Kernel/EntitySubQueueAPITest.php b/tests/src/Kernel/EntitySubQueueAPITest.php index 6d1d8a1dc17e8b93a8a07a343433636a3d51cf2e..dfd92690ff4a8241fff4c23bc4a23f0ad065c6c8 100644 --- a/tests/src/Kernel/EntitySubQueueAPITest.php +++ b/tests/src/Kernel/EntitySubQueueAPITest.php @@ -58,6 +58,12 @@ class EntitySubQueueAPITest extends EntityKernelTestBase { $subqueue->addItem($entity)->save(); $this->assertTrue($subqueue->hasItem($entity)); + + // Field widgets append an empty trailing item to the list. + // @see https://www.drupal.org/project/entityqueue/issues/3618249 + $subqueue->get('items')->appendItem(); + $this->assertTrue($subqueue->hasItem($entity)); + $entity->delete(); $subqueue = EntitySubqueue::load($queue->id()); $this->assertFalse($subqueue->hasItem($entity));