Mark Editor config schema as fully validatable

Created on 4 January 2024, 6 months ago
Updated 7 May 2024, about 2 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 πŸ“Œ [PP-1] Configuration schema & required keys Needs review 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 about 23 hours 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
    6 months ago
    #71690
  • Status changed to Needs work 6 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
    6 months ago
    #71787
  • Pipeline finished with Success
    6 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
    5 months ago
    #80691
  • Pipeline finished with Canceled
    5 months ago
    #80712
  • Pipeline finished with Failed
    5 months ago
    #80713
  • Pipeline finished with Failed
    5 months ago
    #80721
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    @effulgentsia's feedback from #5 has now been addressed πŸ‘

    Next up: #6.2.

  • Pipeline finished with Failed
    5 months ago
    #80729
  • Pipeline finished with Failed
    5 months ago
    #80742
  • Pipeline finished with Failed
    5 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
    5 months ago
    #80788
  • Pipeline finished with Failed
    5 months ago
    #80802
  • Issue was unassigned.
  • Status changed to Needs review 5 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
    5 months ago
    #80815
  • Pipeline finished with Canceled
    5 months ago
    #80830
  • Pipeline finished with Success
    5 months ago
    #80839
  • Pipeline finished with Failed
    5 months ago
    #80859
  • Status changed to Needs work 5 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • Pipeline finished with Failed
    5 months ago
    #80896
  • Pipeline finished with Failed
    5 months ago
    #80925
  • Pipeline finished with Pending
    5 months ago
    #80959
  • Pipeline finished with Failed
    5 months ago
    #81426
  • Pipeline finished with Failed
    5 months ago
    #81477
  • Assigned to phenaproxima
  • Status changed to Needs review 5 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
    5 months ago
    #81507
  • Assigned to Wim Leers
  • Status changed to Needs work 5 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

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

  • Pipeline finished with Success
    5 months ago
    #81805
  • Pipeline finished with Canceled
    5 months ago
    #81860
  • Pipeline finished with Success
    5 months ago
    #81861
  • Pipeline finished with Pending
    5 months ago
    #81901
  • Pipeline finished with Failed
    5 months ago
    #81921
  • Issue was unassigned.
  • Status changed to Needs review 5 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
    5 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
    5 months ago
    #81949
  • Pipeline finished with Failed
    5 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
    5 months ago
    #81975
  • Pipeline finished with Running
    5 months ago
    #82260
  • Pipeline finished with Success
    5 months ago
    #82263
  • Pipeline finished with Success
    5 months ago
    #82266
  • Pipeline finished with Running
    5 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
    5 months ago
    #82714
  • Pipeline finished with Success
    5 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
    5 months ago
    #82717
  • Status changed to RTBC 5 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
    5 months ago
    Total: 575s
    #91192
  • Status changed to Needs work 4 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
    4 months ago
    Total: 565s
    #98717
  • Pipeline finished with Success
    4 months ago
    #98730
  • Issue was unassigned.
  • Status changed to Needs review 4 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
    4 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
    4 months ago
    Total: 482s
    #104255
  • Status changed to RTBC 4 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 4 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
    4 months ago
    Total: 486s
    #104944
  • Status changed to Needs review 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Did what I promised in #30:

  • Pipeline finished with Failed
    4 months ago
    Total: 540s
    #104972
  • Pipeline finished with Success
    4 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 4 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 4 months ago
  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Good remarks :)

  • Pipeline finished with Success
    4 months ago
    Total: 504s
    #105148
  • Status changed to RTBC 4 months ago
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    As promised in #33.

  • πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    Lovely, thank you! 😊

  • Status changed to Needs work 4 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 4 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
    4 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 4 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 πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    This also enables us removing some serious technical debt: πŸ“Œ Deprecate \Drupal\ckeditor5\Plugin\Editor\CKEditor5::validatePair() and `type: ckeditor5_valid_pair__format_and_editor` Active . πŸ‘

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

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

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

Production build 0.69.0 2024