Closed (fixed)
Project:
Drupal core
Version:
8.8.x-dev
Component:
content_moderation.module
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
17 Apr 2019 at 01:39 UTC
Updated:
7 May 2019 at 15:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sam152 commentedComment #4
fenstratThis makes a lot of sense, good catch.
Seems odd calling this "internal" function, but it's already called in LayoutBuilderModerationTest::testModerationWithNodeAndMenuSettings(), so fair enough.
Comment #5
sam152 commentedBumping to major since authored content in the LB is essentially lost/unsavable when this is triggered.
Comment #6
alexpottMy original thought is that this fix looks good but I think we could do with a comment in the code about when this might happen.
However whilst asking myself the question - how does this happen I'm no longer sure.
$entity->menuis added bymenu_ui_node_builder()which is added by a form alter -menu_ui_form_node_form_alter(). But the constraint is added onmenu_ui_entity_type_build()level - so it is always present. Which makes the menu_ui not the most API friendly module. Is there an existing issue which covers this problem?The solution here might be the most pragmatic as a quick fix - but I think we at least need a comment that covers the why.
Comment #7
sam152 commentedEssentially if the entity form is missing the menu UI form elements, the
$entity->menuarray never gets built and the validator does weird things. My assumption was, if no menu form elements were present on the form, the validator doesn't need to protect against changes to the associated menu link.Can add a comment to that effect in the validator.
Comment #8
sam152 commentedComment #9
tedbowThis seems like a good fix and comment.
Looked around for other issues. It seems weird to use Entity constraint for something that is only added via a form. I think if you were doing the same action say over JSON API you would make to POST/PATCH requests because this is actually 2 different content entities. In that case a entity level constraint makes no sense. So that would mean moving from using an entity constraint to I guess form validation function.
If others agree we could make a follow up I think this issue looks good.
Comment #10
alexpottVery happy to explore the correct fix in a follow-up. Let's create that first though.
Comment #11
tedbowCreated #3050199: Remove entity level constraint MenuSettingsConstraint that validates property only added in a form
Comment #12
alexpottCommitted and pushed e07c22588a to 8.8.x and cef261ecea to 8.7.x. Thanks!
As a major bug fix backported to 8.7.x.