diff -u b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php --- b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -304,10 +304,8 @@ // entities created. if ($referenceable = $selection_handler->getReferenceableEntities(NULL, 'CONTAINS', 50)) { $group = array_rand($referenceable); - if (!empty($referenceable[$group])) { - $values['target_id'] = array_rand($referenceable[$group]); - return $values; - } + $values['target_id'] = array_rand($referenceable[$group]); + return $values; } // Attempt to create a sample entity, avoiding recursion. @@ -316,8 +314,10 @@ // entities created. if ($referenceable = $selection_handler->getReferenceableEntities(NULL, 'CONTAINS', 50)) { $group = array_rand($referenceable); - $values['target_id'] = array_rand($referenceable[$group]); - return $values; + if (!empty($referenceable[$group])) { + $values['target_id'] = array_rand($referenceable[$group]); + return $values; + } } // Attempt to create a sample entity, avoiding recursion. diff -u b/core/modules/layout_builder/src/EventSubscriber/WorkspaceSafeForms.php b/core/modules/layout_builder/src/EventSubscriber/WorkspaceSafeForms.php --- b/core/modules/layout_builder/src/EventSubscriber/WorkspaceSafeForms.php +++ b/core/modules/layout_builder/src/EventSubscriber/WorkspaceSafeForms.php @@ -5,7 +5,6 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\layout_builder\SectionStorageInterface; use Drupal\layout_builder\EventSubscriber\WorkspaceSafeForms; -use Drupal\workspaces\Event\WorkspaceSafeFormEvent; use Drupal\workspaces\WorkspaceEvents; use Drupal\workspaces\WorkspaceManagerInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -67,7 +66,7 @@ * @param \Drupal\layout_builder\EventSubscriber\WorkspaceSafeForms $event * The layout_builder event. */ - public function onWorkspaceSafeForm(WorkspaceSafeFormEvent $event) { + public function onWorkspaceSafeForm(WorkspaceSafeForms $event) { if (!in_array($event->getFormId(), static::FORM_IDS, TRUE)) { return; }