Problem/Motivation
This issue is spun off from #3364108-94: Configuration schema & required keys. @effulgentsia said:
My only hesitation ... is the various changes in here related to enforcing the lack of any other keys when an editor's image_upload.status is FALSE. For example, the need to remove those other keys from Umami's editor.editor.basic_html.yml. I think that should all be removed from this MR and moved to a follow-up that gets its own commit and its own change record.
This is that follow-up. Refer to #3364108: Configuration schema & required keys for all the rationale and discussion that brought it about!
Proposed resolution
- First, restructure the config schema for
editor.editor.*:image_upload, to allow making onlyeditor.editor.*:image_upload.statusrequired ALWAYS (for this, the neweditor.image_upload_settings.*type is added). All other keys should be only required if that is set totrue(for this, the neweditor.image_upload_settings.1type is added). - Second, mark the following types as fully validatable:
editor.editor.*(aka the config schema type for theEditorconfig entity type)editor.image_upload_settings.*(contains onlystatus)editor.image_upload_settings.1(contains everything else: upload directory, max size, etc.)
- In order to make all those fully validatable, some changes/additions are needed to perform the necessary validation:
- to
ConfigExists→ #3422398: Allow specifying a prefix for ConfigExistsConstraint, to enable using it for references to config entities - a new
type: bytes+ a newCallbackValidatorcallback:\Drupal\Component\Utility\Bytes::validateConstraint()→ #3422407: New config schema data type: bytes - a new
ChoiceValidatorcallback:\Drupal\editor\Entity\Editor::getValidStreamWrappers()
- to
- An automatic update path to:
- convert
editor.editor.*:image_upload.directoryfrom''tonull(to indicate that the root of the chosen stream wrapper should be used) - convert
editor.editor.*:image_upload.max_sizefrom''tonull(to indicate that there is no lower file upload limit than the maximum allowed by the current PHP environment) - convert
editor.editor.*:image_upload.max_dimensions.widthfrom0tonull(to indicate that there is no max width) - convert
editor.editor.*:image_upload.max_dimensions.heightfrom0tonull(to indicate that there is no max height)
- convert
- One addition to the list of ignored property paths, due to a newly discovered edge case bug deep in the config system: #3416735: Stream wrappers not registered when installing module's default config — but only the validation error message for when this edge case occurs is ignored 👍
- Minimize changes to tests: only missing required keys were added. When the necessary keys were present, incorrect values (such as a max width of
0) can remain in place in tests, they are automatically updated by theeditor_editor_presave-powered update path. This proves that we'll be able to minimize contrib disruption, and allow for gradual updates. Instead of54 files,+838,-115, this made the MR35 files,+734,-92.
API changes
No changes, but 1 API addition:
- To make
editor.editor.*:image_upload.schemevalidatable,\Drupal\editor\Entity\Editor::getValidStreamWrappers()was added
Issue fork drupal-3412361
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3412361-ckeditor5-validatable
changes, plain diff MR !6026
Comments
Comment #2
phenaproximaComment #4
effulgentsia commentedI committed the blocker issue, so this isn't postponed anymore.
Comment #5
effulgentsia commentedSomething to think about here is upgrade path:
status=FALSE. Do we want a postupdate function to remove those?Comment #6
wim leersRE #5:
hook_post_update_SOMETHING(), but to do it inckeditor5_editor_presave()(for CKE5-specific things) oreditor_editor_presave()(for genericEditorthings) and have the post-update hook merely iterate over allEditorconfig entities and detect whether it needs an update, and if so, resave it. That way, install profiles are also handled! 👍Review
Editorchanges are much wider/broader than the CKEditor 5 changes (which are just marking already validatable things asFullyValidatable)editor.editor.*is being marked asFullyValidatablebut … it isn't really.is not yet validatable! We need to validate that if the value is
FOO, that afilter.format.FOOconfig entity exists.Comment #7
wim leersComment #8
wim leers@effulgentsia's feedback from #5 has now been addressed 👍
Next up: #6.2.
Comment #9
wim leers#6.2 is now addressed.
Next up (the last thing): #6.1. Created #3416223: Opt in already validatable CKEditor 5 text editor settings + configurable CKEditor 5 plugin's settings to FullyValidatable for that. That should allow this MR to be much smaller, and only touch
editor-related changes, notckeditor5-related changes 👍Comment #10
wim leersChange record created for the new functionality of
ConfigExists: https://www.drupal.org/node/3416240Comment #11
phenaproximaComment #12
wim leersAddressed @phenaproxima's feedback on the MR 👍
Still to be done tomorrow by yours truly: validation for
editor.editor.*:image_upload.max_size.Comment #13
phenaproximaA few requests for comments, but I think this is looking quite good!
Comment #14
wim leersReady for review again, with everything addressed 🤓
Change record created for
type: bytes: https://www.drupal.org/node/3416738.Comment #15
borisson_I think it makes sense to introduce
byteshere, because that gives it a use already. Making max_size nullable looks like it some more fallout than expected, looking at the tests that are currently failing still?Comment #16
wim leersBut that's necessary, because
''is not a sensible value for "no limit". All green now — it wasn't too complicated, it was just a small oversight on my behalf 🙈Comment #17
wim leersMR is green, and tighter in scope after a thorough self-review.
Issue summary updated, it is now complete. 👍
Comment #18
phenaproximaOnly a couple of questions but otherwise I'm quite happy with this!
Comment #19
wim leers🥳 Should be RTBC'able now! 😄
Comment #20
wim leersExplain why
type: bytesmakes sense in the issue summary.Comment #21
borisson_I agree with #19, this is rtbcable. In most of these issues we will need signoff from the subsystem maintainer as well - I don't think that is explicitly needed here, since Wim is Wim already :)
Comment #22
phenaproximaAll my complaints and points are resolved. +1 RTBC! #shipit
Comment #23
catchMoving this to needs work for the outstanding feedback on the MR.
I'm also wondering if the changes that are outside Editor module could be done in their own issue before this one?
Comment #24
wim leersComment #25
wim leersAddressed! 🏓
There's a few bits we can extract:
Comment #26
wim leersComment #27
wim leers#3422398: Allow specifying a prefix for ConfigExistsConstraint, to enable using it for references to config entities landed, rebased MR 👍 3 fewer files changed :)
Comment #28
wim leers#3422407: New config schema data type: bytes also landed! Rebased MR again. Another 3 fewer files changed.
Comment #29
phenaproximaEverything in here makes sense to me. The weird parts are well-explained and commented. I feel pretty good slapping the RTBC on this!
Comment #30
wim leersFixed a few details in the issue summary.
I'd like to tighten test coverage slightly more, for maximum confidence that this will not cause regressions.
Comment #31
wim leersDid what I promised in #30:
makes the kernel test coverage more complete
editor.editor.*:image_upload, whose settings are presented by the\Drupal\ckeditor5\Plugin\CKEditor5Plugin\Imageplugin and still is a good citizen by reusingeditor_image_upload_settings_form(), actually is A) correctly validated, B) still can be saved (🙈 in manual testing I discovered that it actually could not be saved in its prior RTBC state, because we only had kernel tests! 🙈)Comment #32
wim leersPassing again 😊🚀
Now I'm confident this will not cause any problems for sites updating to this version 👍
Comment #33
phenaproximaLiking the new test coverage! I have nits, and only one is blocking (an assert that doesn't actually assert anything). But otherwise, happy to restore RTBC once the one thing is fixed.
Comment #34
wim leersGood remarks :)
Comment #35
phenaproximaAs promised in #33.
Comment #36
wim leersLovely, thank you! 😊
Comment #37
catchNeeds work for one point on the MR.
The other one probably isn't blocking but feels like a good idea.
Comment #38
wim leersOne trivial change, so re-self RTBC'ing.
I proposed on the MR to do this for all the recent occurrences of this in a single issue, so that it all is consistent, and they all become simple to remove.
Tagged for that, I hope you agree :)
Comment #39
catchThe main example is ViewsConfigUpdater, but also a whole class seems like overkill for modules that might only have one config entity update in an entire major release. Follow-up is fine.
Yes much better :)
Comment #40
catchCommitted/pushed to 11.x and cherry-picked to 10.3.x, thanks!
Comment #44
wim leersThis unblocked #2300677: JSON:API POST/PATCH support for fully validatable config entities 🚀
Will definitely create that follow-up 👍
Comment #45
wim leersThis also enables us removing some serious technical debt: #3425349: [PP-1] Deprecate \Drupal\ckeditor5\Plugin\Editor\CKEditor5::validatePair() and `type: ckeditor5_valid_pair__format_and_editor`. 👍
Comment #47
catchFollow-up here #3442395: ckeditor5 and editor module test config exports/stubs rely on hook_editor_presave() bc layers.
Comment #48
quietone commented@catch, thanks for pointing out the followup. I am removing the tag.
Comment #49
catchThe upgrade path added here introduces a fatal error if a filter format has gone missing, I think just because the editor config gets resaved when it might not have been previously, this is in #3463524: editor_post_update_sanitize_image_upload_settings fails on missing text format.