- Issue created by @kristiaanvandeneynde
- 🇧🇪Belgium kristiaanvandeneynde Antwerp, Belgium
My preferred solution is to only save the display once. It's being saved multiple times for each loop iteration, that's just unnecessary.
The function _scheduler_form_entity_type_submit has the following line:
$form_display = $display_repository->getFormDisplay($entity_type_id, $bundle_id, $display_mode);
And then calls $form_display->someChainableStuff()->save()
a bunch of times below that. However, getFormDisplay() will return a newly created config entity because nothing existed yet. It seems that calling save multiple times on said newly created entity will lead to the following exception being thrown:
Drupal\Core\Config\ConfigDuplicateUUIDException: Attempt to save a configuration entity 'taxonomy_term.testing.default' with UUID '' when this entity already exists with UUID '9b85d17b-68ab-49cb-9f74-71e157da4287' in Drupal\Core\Config\Entity\ConfigEntityBase->preSave() (line 318 of core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php).
This is because the initial entity has no UUID, gets one on the first save and then you try to reset that to NULL by saving the initially created entity again.
You could argue it's a core bug and that the UUID field needs to be populated after the first save. But the problem definitely manifests itself in this module.
Check the entity for isNew() and adjust accordingly or only save the display once at the bottom of the submit handler.
/
/
/
Active
2.1
Code
My preferred solution is to only save the display once. It's being saved multiple times for each loop iteration, that's just unnecessary.