- π³πΏNew Zealand danielveza Brisbane, AU
This came up as a daily target for the Bug smash initiative. I've checked out the code and the entity isn't validated before it's saved.
\Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::save
call $this->getEntity()->save()
but ::validate()
never called on the entity.
This means that the entity could be saved with invalid values.
This came up in discussing #2973382: [meta] Decide how Layout Builder should function with Content Moderation and Workspaces modules β because the entity for instance could be in Archived moderation state where it can't be save unless the moderation state is change to either Published or Draft
No calling ::validate()
also means that you could not effectively but constraints on the layout field itself that would be in effect when saving the Layout both programmatically and through the UI. For instance you may want to add a field constraint that the layout can't have over 10 sections or that you can't place a custom "Header" block in any section except the top.
Call $this->getEntity()->validate()
before saving in \Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::save()
and throw exceptions if any are found.
This means that both \Drupal\layout_builder\Controller\LayoutBuilderController::saveLayout()
would have to display and messages and not save.
\Drupal\layout_builder\Form\RevertOverridesForm
should also probably override validateForm
and call $this->getEntity()->validate()
directly.
Write patch and review
The user will be given error message if they try to save a layout when the entity does not validate.
None
None
Active
11.0 π₯
Last updated
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
This came up as a daily target for the Bug smash initiative. I've checked out the code and the entity isn't validated before it's saved.