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

  1. First, restructure the config schema for editor.editor.*:image_upload, to allow making only editor.editor.*:image_upload.status required ALWAYS (for this, the new editor.image_upload_settings.* type is added). All other keys should be only required if that is set to true (for this, the new editor.image_upload_settings.1 type is added).
  2. Second, mark the following types as fully validatable:
    • editor.editor.* (aka the config schema type for the Editor config entity type)
    • editor.image_upload_settings.* (contains only status)
    • editor.image_upload_settings.1 (contains everything else: upload directory, max size, etc.)
  3. In order to make all those fully validatable, some changes/additions are needed to perform the necessary validation:
  4. An automatic update path to:
    • convert editor.editor.*:image_upload.directory from '' to null (to indicate that the root of the chosen stream wrapper should be used)
    • convert editor.editor.*:image_upload.max_size from '' to null (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.width from 0 to null (to indicate that there is no max width)
    • convert editor.editor.*:image_upload.max_dimensions.height from 0 to null (to indicate that there is no max height)
  5. 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 👍
  6. 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 the editor_editor_presave -powered update path. This proves that we'll be able to minimize contrib disruption, and allow for gradual updates. Instead of 54 files,+838,-115, this made the MR 35 files,+734,-92.

API changes

No changes, but 1 API addition:

  1. To make editor.editor.*:image_upload.scheme validatable, \Drupal\editor\Entity\Editor::getValidStreamWrappers() was added

Issue fork drupal-3412361

Command icon 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:

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Issue summary: View changes

effulgentsia’s picture

Title: [PP-1] Mark parts of CKEditor 5 and Editor config schema as fully validatable » Mark parts of CKEditor 5 and Editor config schema as fully validatable
Status: Postponed » Needs work

I committed the blocker issue, so this isn't postponed anymore.

effulgentsia’s picture

Something to think about here is upgrade path:

  1. Sites might have active config with keys that this MR makes invalid when status=FALSE. Do we want a postupdate function to remove those?
  2. There might be contrib/custom modules/profiles with default config that includes these now-invalid keys. Do we want something that runs on module-enable and/or config-import that removes them?
wim leers’s picture

Title: Mark parts of CKEditor 5 and Editor config schema as fully validatable » Mark Editor config schema as fully validatable
Component: ckeditor5.module » editor.module
Priority: Normal » Major
Issue tags: +Configuration schema, +validation

RE #5:

  1. Yes, but … see point 2 👍 (and I don't know why I didn't do that in the original issue — shame on me — that's another great reason to have this split off 👍)
  2. The correct pattern that @catch has repeatedly pointed me to is to NOT do the actual update logic in a hook_post_update_SOMETHING(), but to do it in ckeditor5_editor_presave() (for CKE5-specific things) or editor_editor_presave() (for generic Editor things) and have the post-update hook merely iterate over all Editor config entities and detect whether it needs an update, and if so, resave it. That way, install profiles are also handled! 👍

Review

  1. I actually think it'd be better to split up this issue too: the Editor changes are much wider/broader than the CKEditor 5 changes (which are just marking already validatable things as FullyValidatable)
  2. editor.editor.* is being marked as FullyValidatable but … it isn't really.
      mapping:
        format:
          type: string
          label: 'Name'
    

    is not yet validatable! We need to validate that if the value is FOO, that a filter.format.FOO config entity exists.

wim leers’s picture

Assigned: Unassigned » wim leers
wim leers’s picture

@effulgentsia's feedback from #5 has now been addressed 👍

Next up: #6.2.

wim leers’s picture

#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, not ckeditor5-related changes 👍

wim leers’s picture

Assigned: wim leers » Unassigned
Issue summary: View changes
Status: Needs work » Needs review

Change record created for the new functionality of ConfigExists: https://www.drupal.org/node/3416240

phenaproxima’s picture

Status: Needs review » Needs work
wim leers’s picture

Assigned: Unassigned » phenaproxima
Issue summary: View changes
Status: Needs work » Needs review

Addressed @phenaproxima's feedback on the MR 👍

Still to be done tomorrow by yours truly: validation for editor.editor.*:image_upload.max_size.

phenaproxima’s picture

Assigned: phenaproxima » wim leers
Status: Needs review » Needs work

A few requests for comments, but I think this is looking quite good!

wim leers’s picture

Assigned: wim leers » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
Issue tags: +API addition
Related issues: +#3416735: Stream wrappers not registered when installing module's default config

Ready for review again, with everything addressed 🤓

Change record created for type: bytes: https://www.drupal.org/node/3416738.

borisson_’s picture

I think it makes sense to introduce bytes here, 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?

wim leers’s picture

Making max_size nullable looks like it some more fallout than expected, looking at the tests that are currently failing still?

But 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 🙈

wim leers’s picture

Issue summary: View changes

MR is green, and tighter in scope after a thorough self-review.

Issue summary updated, it is now complete. 👍

phenaproxima’s picture

Only a couple of questions but otherwise I'm quite happy with this!

wim leers’s picture

🥳 Should be RTBC'able now! 😄

wim leers’s picture

Issue summary: View changes

Explain why type: bytes makes sense in the issue summary.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

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 :)

phenaproxima’s picture

All my complaints and points are resolved. +1 RTBC! #shipit

catch’s picture

Status: Reviewed & tested by the community » Needs work

Moving 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?

wim leers’s picture

Assigned: Unassigned » wim leers
wim leers’s picture

Title: Mark Editor config schema as fully validatable » [PP-2] Mark Editor config schema as fully validatable
Assigned: wim leers » Unassigned
Issue summary: View changes
Status: Needs work » Needs review

Moving this to needs work for the outstanding feedback on the MR.

Addressed! 🏓

I'm also wondering if the changes that are outside Editor module could be done in their own issue before this one?

There's a few bits we can extract:

wim leers’s picture

wim leers’s picture

Title: [PP-2] Mark Editor config schema as fully validatable » [PP-1] Mark Editor config schema as fully validatable
wim leers’s picture

Title: [PP-1] Mark Editor config schema as fully validatable » Mark Editor config schema as fully validatable

#3422407: New config schema data type: bytes also landed! Rebased MR again. Another 3 fewer files changed.

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

Everything in here makes sense to me. The weird parts are well-explained and commented. I feel pretty good slapping the RTBC on this!

wim leers’s picture

Assigned: Unassigned » wim leers
Issue summary: View changes
Status: Reviewed & tested by the community » Needs work

Fixed 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.

wim leers’s picture

Status: Needs work » Needs review

Did what I promised in #30:

wim leers’s picture

Assigned: wim leers » Unassigned

Passing again 😊🚀

Now I'm confident this will not cause any problems for sites updating to this version 👍

phenaproxima’s picture

Status: Needs review » Needs work

Liking 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.

wim leers’s picture

Status: Needs work » Needs review

Good remarks :)

phenaproxima’s picture

Status: Needs review » Reviewed & tested by the community

As promised in #33.

wim leers’s picture

Lovely, thank you! 😊

catch’s picture

Status: Reviewed & tested by the community » Needs work

Needs work for one point on the MR.

The other one probably isn't blocking but feels like a good idea.

wim leers’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: +Needs followup

One trivial change, so re-self RTBC'ing.

The other one probably isn't blocking but feels like a good idea.

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 Needs followup for that, I hope you agree :)

catch’s picture

I haven't seen this anywhere in Drupal core?

The 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.

$max_filesize = $settings['max_size']
? Bytes::toNumber($settings['max_size'])
: Environment::getUploadMaxSize();

Yes much better :)

catch’s picture

Version: 11.x-dev » 10.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x and cherry-picked to 10.3.x, thanks!

  • catch committed c5f33469 on 10.3.x
    Issue #3412361 by Wim Leers, phenaproxima, catch, effulgentsia: Mark...

  • catch committed 83874f2b on 11.x
    Issue #3412361 by Wim Leers, phenaproxima, catch, effulgentsia: Mark...

wim leers’s picture

Assigned: Unassigned » wim leers

This unblocked #2300677: JSON:API POST/PATCH support for fully validatable config entities 🚀

Will definitely create that follow-up 👍

wim leers’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

catch’s picture

quietone’s picture

Issue tags: -Needs followup

@catch, thanks for pointing out the followup. I am removing the tag.

catch’s picture

The 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.