Problem/Motivation
While working on #2556617: [regression] Disabled format still filters and displays the value and #2555973: Fatal error when editing content after disabling format with editor I found that when a text format is disabled (or enabled) the paired editor is not synchronizing as status. While I cannot see right now an application for this fix, I still think that text format and the editor should be in sync. But it's still a minor issue.
Proposed resolution
Sync the editor status with the corresponding text format status. i.e. when disabling the text format, the text editor should be disabled as well.
Remaining tasks
None.
User interface changes
None.
API changes
None.
Data model changes
None.
Beta phase evaluation
Issue category | Task because adds status synchronization between a text format and its paired editor. |
---|---|
Issue priority | Not critical because right now no functionality is broken. |
Disruption | No disruption |
Comment | File | Size | Author |
---|---|---|---|
#29 | interdiff.txt | 1.65 KB | claudiu.cristea |
#29 | 2557265-29.patch | 8.38 KB | claudiu.cristea |
#22 | 1.png | 58.55 KB | claudiu.cristea |
#22 | 0.png | 107.63 KB | claudiu.cristea |
Comments
Comment #2
claudiu.cristeaPatch.
Comment #3
claudiu.cristeaComment #5
claudiu.cristeaThe main patch passed.
Comment #6
Wim LeersThis is sad :(
Can't we use
hook_ENTITY_TYPE_presave()
?Nit: one missing asterisk :P
Comment #7
claudiu.cristeaI would say that the sad part is that we cannot detect the configurable type in a subscriber like this. This makes the config events dispatching/subscribing so useless :(
We can use presave hook but I wonder if we cannot improve the config event dispatching to receive also the type of config along with the event object. Using hooks seems to me a step back now if we already have events.EDIT: Forget the last paragraph.
Comment #8
claudiu.cristea@Wim Leers, OK. Here's one with hook presave.
Comment #9
claudiu.cristeaOuch. Forgot the asterisk.
Comment #10
claudiu.cristeaSmall fixes in test.
Comment #11
Wim LeersOh, yes, absolutely. Your patch is great, the API forcing us to do this is sad. I wonder if we're just missing something. But in any case, a cleaner solution exists, using hooks. And I suspect that's exactly why things work the way they do :)
Many thanks for working on this!
I have only nits:
You can typehint to
\Drupal\filter\Entity\FilterFormat
:)s/an editor/a text editor/
Same typehint.
s/exit here/return early/
Let's use strict equality.
\Drupal\editor\Entity\Editor
We don't use
$editor
anywhere. So can be simplified toEditor::create(…)->save()
AFAICT :)Comment #12
claudiu.cristeaThank you for review.
Comment #13
Wim LeersI was going to RTBC this, but then I realized that we probably also want to test the inverse direction: when re-enabling a text format, the text editor should be re-enabled also.
Other than that, this looks perfect :)
Comment #14
claudiu.cristeaOK.
Comment #15
Wim LeersWonderful! This is a great patch :)
Without a beta evaluation, this likely won't go in for some time though. But marking RTBC already, to signal that it is indeed ready.
Comment #16
claudiu.cristeaBeta evaluation.
Comment #19
claudiu.cristeaIn #17 it was a random bot failure. Re-RTBC as per #15.
Comment #20
xjmThis sounds like a bug actually, and maybe a bit of a data integrity issue even. What happens in HEAD if a text format with or without existing content is disabled and then someone tries to use the editor for it? What happens if it's disabled and then re-enabled? What happens if one or the other is disabled via a config deployment? Some manual testing of both HEAD and the patch would be good to see what the implications are and if there's a bigger bug lurking here. Anyway, recategorizing the issue so it gets more visibility.
Also, @alexpott and I agreed that this would probably need an upgrade path, particularly for existing sites where text formats had already been disabled, to ensure that the existing configuration is updated and consistent.
Comment #21
claudiu.cristeaA nice integration of editor with text format would have been if Editor would write its settings directly into format as third-party settings. No more headache :)
EDIT: I see this as typical use-case of third-party settings.
Comment #22
claudiu.cristeaThere's no direct effect of this inconsistency in UI. I manually tested this. I created a node with 'basic_html' format (see the first picture) an tried to edit after disabled the format (2nd picture). The body field became disabled but that is the expected behaviour. Then I re-enabled the formatting the API as this cannot be done from UI and the node edit form went to normal as in 1st picture.
After disabling basic_html
Comment #23
claudiu.cristeaAssigning to @Wim Leers for review.
Comment #28
Wim LeersEditor module predates the concept of third-party settings.
Upgrade path looks great to me. Just one nit that can be fixed on commit.
Nit: two spaces instead of one.
Comment #29
claudiu.cristeaFixed the double spacing.
Comment #30
Wim LeersHeh, thanks :) It's fine to keep the patch at RTBC if you're only making whitespace changes ;) :)
Comment #31
alexpottThis has test coverage and upgrade path and fixes a bug so permitted during beta. Committed 40fa14b and pushed to 8.0.x. Thanks!