Closed (fixed)
Project:
Drupal core
Version:
8.4.x-dev
Component:
content_moderation.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Jan 2017 at 18:55 UTC
Updated:
4 Jul 2017 at 09:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sam152 commentedQuick test case for this bug.
Comment #3
sam152 commentedComment #4
sam152 commentedComment #6
sam152 commentedAnd the fix. The entity isn't required during validation, so this works.
Comment #8
scott_euser commentedI have taken a look at your patch, it took a bit to figure out how to reproduce the error but once I did I can confirm your patch solves it.
Steps followed:
Saving before patch, white screen with fatal error as you described.
Saving after patch, drupal form error message as is desirable.
Nice work!
Comment #9
tstoecklerThis kind of an override is very problematic as it can lead to unexpected behavior when calling
buildEntity()in other places.I am providing an alternate patch that simply duplicates the validation in
copyFormValuesToEntity().If you do not like duplication and you see the fact that unvalidated form values are put into entity objects as problematic, see you in #2813073: Don't update $this->entity in EntityForm::afterBuild(). For the scope of this issue, I think this is all we can do.
Comment #10
tstoecklerOops, should have included the test in the patch as well.
Comment #12
berdirHm, this (the previous patch at least, this is a crosspost with @tstoeckler) is problematic, because if we don't build the entity then this prevents us from ever relying on using the entity validation/constraint API for config entities as well.
IMHO a better fix would be to not let the workflow entity explode like this. This doesn't happen with any other config entity AFAIK..
Comment #13
berdirAs I said, crosspost.
Comment #14
sam152 commentedCan the entity validation/constraint API be used for config entities as well?
Comment #15
scott_euser commentedHere is a different approach, it appears to save and work as expected but fatal error is avoided by waiting until form state validation is completed first (perhaps has something to do with the 'This is fired twice', but I couldn't see why it is fired twice).
Comment #16
hchonovWell currently it is not right that the entity is built twice on submission as it might happen that we save an entity that is not validated because of the entity builders. There is an issue to avoid this for content entities, but the approach might be used for config entities as well - #2833682: In submit use the entity built during the validation instead of building it again - for performance and consistency ensuring we are saving the entity that has been validated.
Comment #18
hchonovComment #20
scott_euser commentedI am not sure if there is anything relying on that or further consequences of that if any, but hopefully someone who knows the ins and outs of workflow can review that. Otherwise my patch in #15 should solve the issue without knock-on effects.
Perhaps preventing double build can be addressed in a separate issue so solving this one isn't held up?
Comment #21
timmillwoodI agree with @hchonov that it is not right that the entity is built twice on submission, but I don't think that is for this issue. To fix the issue in hand I like the solution in #15, but would also be happy if #10 were committed.
I don't think we need to fix all the underlying issues here, just prevent the user from seeing a WSOD.
Comment #22
hchonovWell if we fix all the issues by a way where the entity builders are checking that they've already run and that the result from the previous execution is already there then we are only curing the symptoms but not the problem itself and we have to start at some point when there is an issue really showing the problem...
Comment #23
scott_euser commentedResubmitting #15 so it's the latest for review to at least fix the WSOD.
Comment #24
scott_euser commentedWould help if I attached it...
Comment #25
tstoecklerMhh, I guess we need a maintainer's input about this. With the three patches and @Berdir's comment we have 4 different directions to go in...
Comment #26
scott_euser commentedAh I thought from your comment in #21 I'd resubmit to keep things moving, sorry!
Comment #27
tstoecklerDiscussed this with @timmillwood and @Berdir in IRC (see attached log). We (at least Berdir and I) agreed that while my patch is ugly in that it duplicates the validation logic it is the best we can do given the current state of form validation vs. entity validation vs. form building etc.
Re-uploading my patch.
Comment #28
scott_euser commentedSounds good. I don't know my regular expressions very well; do the @ signs before and after that machine name uses in its validation make a difference? If so, perhaps we should match that?
!preg_match('@[^a-z0-9_]+@', $values['id'])Comment #29
sam152 commentedComment #30
sam152 commentedComment #31
tstoecklerRe #28, no it really doesn't make a difference. The version I chose is the one used in
Workflow::addState()so I think it should be fine.Comment #32
wim leersNit: Can we have a failing test-only patch? That'll make it easier for committers.
Comment #33
sam152 commentedComment #35
sam152 commentedComment #36
timmillwood+1 to RTBC
Comment #37
larowlanShould we link this issue to #2164373: [META] Untie config validation from form validation — enables validatable Recipes, decoupled admin UIs … because we're adding validation that only runs in a form? I.e. to move to validation constraints once they're supported for config entities?
Given what we have to work with, I think this is the best we can do.
Comment #38
larowlanAdded related items, including #2845517: Enforce allowed characters of machine names in config entities. which is directly related.
Comment #39
larowlanUpdating issue credits
Comment #40
larowlanReviewed this.
We have buy in from the maintainer (@timmillwood) and entity subsystem maintainers (@Berdir, @tstoeckler) and we have a follow-up for cleaning this up - #2845517: Enforce allowed characters of machine names in config entities.
This fixes the fatal/WSOD seen in the UI.
Committed 6d68ffd and pushed to 8.4.x. Thanks!
Comment #42
timmillwoodThis seems related to #2886567: Adding a workflow state or transition with an integer ID results in unrecoverable fatal errors.