Mark Editor config schema as fully validatable

Created on 4 January 2024, 11 months ago
Updated 29 July 2024, 4 months ago

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 📌 Configuration schema & required keys Fixed 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: 🐛 Stream wrappers not registered when installing module's default config Active — 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
Feature request
Status

Fixed

Version

10.3

Component
Editor 

Last updated 17 days ago

Created by

🇺🇸United States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
  • API addition

    Enhances an existing API or introduces a new subsystem. Depending on the size and impact, possibly backportable to earlier major versions.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @phenaproxima
  • 🇺🇸United States phenaproxima Massachusetts
  • Pipeline finished with Success
    11 months ago
    #71690
  • Status changed to Needs work 11 months ago
  • 🇺🇸United States effulgentsia

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

  • 🇺🇸United States effulgentsia

    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?
  • Pipeline finished with Canceled
    11 months ago
    #71787
  • Pipeline finished with Success
    11 months ago
    #71788
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    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.

  • Assigned to wim leers
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • Pipeline finished with Success
    10 months ago
    #80691
  • Pipeline finished with Canceled
    10 months ago
    #80712
  • Pipeline finished with Failed
    10 months ago
    #80713
  • Pipeline finished with Failed
    10 months ago
    #80721
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

    Next up: #6.2.

  • Pipeline finished with Failed
    10 months ago
    #80729
  • Pipeline finished with Failed
    10 months ago
    #80742
  • Pipeline finished with Failed
    10 months ago
    #80769
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    #6.2 is now addressed.

    Next up (the last thing): #6.1. Created 📌 Mark config schema for CKEditor 5 text editor settings + each configurable CKEditor 5 plugin as FullyValidatable Active for that. That should allow this MR to be much smaller, and only touch editor-related changes, not ckeditor5-related changes 👍

  • Pipeline finished with Success
    10 months ago
    #80788
  • Pipeline finished with Failed
    10 months ago
    #80802
  • Issue was unassigned.
  • Status changed to Needs review 10 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

  • Pipeline finished with Success
    10 months ago
    #80815
  • Pipeline finished with Canceled
    10 months ago
    #80830
  • Pipeline finished with Success
    10 months ago
    #80839
  • Pipeline finished with Failed
    10 months ago
    #80859
  • Status changed to Needs work 10 months ago
  • 🇺🇸United States phenaproxima Massachusetts
  • Pipeline finished with Failed
    10 months ago
    #80896
  • Pipeline finished with Failed
    10 months ago
    #80925
  • Pipeline finished with Pending
    10 months ago
    #80959
  • Pipeline finished with Failed
    10 months ago
    #81426
  • Pipeline finished with Failed
    10 months ago
    #81477
  • Assigned to phenaproxima
  • Status changed to Needs review 10 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Addressed @phenaproxima's feedback on the MR 👍

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

  • Pipeline finished with Failed
    10 months ago
    #81507
  • Assigned to wim leers
  • Status changed to Needs work 10 months ago
  • 🇺🇸United States phenaproxima Massachusetts

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

  • Pipeline finished with Success
    10 months ago
    #81805
  • Pipeline finished with Canceled
    10 months ago
    #81860
  • Pipeline finished with Success
    10 months ago
    #81861
  • Pipeline finished with Pending
    10 months ago
    #81901
  • Pipeline finished with Failed
    10 months ago
    #81921
  • Issue was unassigned.
  • Status changed to Needs review 10 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Ready for review again, with everything addressed 🤓

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

  • Pipeline finished with Failed
    10 months ago
    #81936
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

    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?

  • Pipeline finished with Failed
    10 months ago
    #81949
  • Pipeline finished with Failed
    10 months ago
    #81966
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    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 🙈

  • Pipeline finished with Success
    10 months ago
    #81975
  • Pipeline finished with Running
    10 months ago
    #82260
  • Pipeline finished with Success
    10 months ago
    #82263
  • Pipeline finished with Success
    10 months ago
    #82266
  • Pipeline finished with Running
    10 months ago
    #82301
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

    Issue summary updated, it is now complete. 👍

  • 🇺🇸United States phenaproxima Massachusetts

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

  • Pipeline finished with Canceled
    10 months ago
    #82714
  • Pipeline finished with Success
    10 months ago
    #82715
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    🥳 Should be RTBC'able now! 😄

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

  • Pipeline finished with Success
    10 months ago
    #82717
  • Status changed to RTBC 10 months ago
  • 🇧🇪Belgium borisson_ Mechelen, 🇧🇪

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

  • 🇺🇸United States phenaproxima Massachusetts

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

  • Pipeline finished with Failed
    9 months ago
    Total: 575s
    #91192
  • Status changed to Needs work 9 months ago
  • 🇬🇧United Kingdom catch

    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?

  • Assigned to wim leers
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • Pipeline finished with Failed
    9 months ago
    Total: 565s
    #98717
  • Pipeline finished with Success
    9 months ago
    #98730
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    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:

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • Pipeline finished with Success
    9 months ago
    Total: 519s
    #104238
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

  • Pipeline finished with Success
    9 months ago
    Total: 482s
    #104255
  • Status changed to RTBC 9 months ago
  • 🇺🇸United States phenaproxima Massachusetts

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

  • Assigned to wim leers
  • Status changed to Needs work 9 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    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.

  • Pipeline finished with Failed
    9 months ago
    Total: 486s
    #104944
  • Status changed to Needs review 9 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Did what I promised in #30:

  • Pipeline finished with Failed
    9 months ago
    Total: 540s
    #104972
  • Pipeline finished with Success
    9 months ago
    Total: 496s
    #104982
  • Issue was unassigned.
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Passing again 😊🚀

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

  • Status changed to Needs work 9 months ago
  • 🇺🇸United States phenaproxima Massachusetts

    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.

  • Status changed to Needs review 9 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Good remarks :)

  • Pipeline finished with Success
    9 months ago
    Total: 504s
    #105148
  • Status changed to RTBC 9 months ago
  • 🇺🇸United States phenaproxima Massachusetts

    As promised in #33.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Lovely, thank you! 😊

  • Status changed to Needs work 9 months ago
  • 🇬🇧United Kingdom catch

    Needs work for one point on the MR.

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

  • Status changed to RTBC 9 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

  • Pipeline finished with Success
    9 months ago
    Total: 483s
    #108119
  • 🇬🇧United Kingdom catch

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

  • Status changed to Fixed 9 months ago
  • 🇬🇧United Kingdom catch

    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...
  • Assigned to wim leers
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    This unblocked [PP-2] POST/PATCH config entities via REST for config entity types that support validation Needs work 🚀

    Will definitely create that follow-up 👍

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • Automatically closed - issue fixed for 2 weeks with no activity.

  • 🇳🇿New Zealand quietone

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

  • 🇬🇧United Kingdom catch

    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 🐛 editor_post_update_sanitize_image_upload_settings fails Needs review .

Production build 0.71.5 2024