Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
configuration system
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
18 Dec 2014 at 14:39 UTC
Updated:
5 Jan 2015 at 16:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
alexpottAdding the event listener means that deleted configuration objects are always removed from the static cache - so we can improve so of the ConfigFactory code to have a little less complexity.
Comment #4
wim leersApparently a test failure in CKEditor module's tests. Taking a look at this.
Comment #5
wim leersReproduced, in both the test, and through manual testing. At some point, a
FlattenExceptionis thrown that becomes too large to handle. It specifically happens when enabling the 'Styles Combo' plugin through the UI, after whicheditor_form_filter_admin_format_submit()calls$editor->save(). And now the party begins. Let's follow the stack trace.Editor::save()->ConfigEntityStorage->save()->EntityStorageBase::save()->ConfigEntityBase::preSave()Here something interesting happens:
We load the unchanged entity. In there, we break. Let's continue following the stack trace.
EntityStorageBase::loadUnchanged()(to do this, it rests its own static cache) ->EntityStorageBase::load()->EntityStorageBase::loadMultiple()->EntityStorageBase::doLoadMultiple()->EntityStorageBase::mapFromStorageRecords()->Editor::__construct()Another particularly interesting point is hit here, in the constructor. Because that looks like this:
Turns out
$this->editor === NULL, and hence no plugin is found (now if only we could havestringtypehints, then we'd have found it much easier…).The cause for that is that
ConfigEntityStorage::doLoadMultiple()callsConfigEntityStorage::mapFromStorageRecords()with$records = [0 => ''], which then results in entity constructor calls with$values = [], hence$this->editornever is set.So… what is the root cause of us getting
$records = [0 => '']? Something goes wrong in this code inConfigEntityStorage, so let's dive deeper there:So, somewhere in
ConfigFactory::loadMultiple(), things are going wrong. And yes, this patch does change that method:However, undoing these changes does not fix the problem for me.
So: I don't know the solution, but at least you should now have a good starting point.
To get to the same debugging, add a conditional breakpoint on this line (currently line 181) in
ConfigEntityStorage:with the following condition:
Then go to
admin/config/content/formats/manage/restricted_html, enable CKEditor, save it. Then go back to that form, add the "Styles" button, type something valid in its settings, enable XDebug, and now you will hit that conditional breakpoint.Comment #6
gábor hojtsyCritical due to #2392319-19: Config objects (but not config entities) should by default be immutable by @alexpott.
Comment #8
catch#2386571: Large array structures (e.g. $form) in stack trace results in huge memory usage in FlattenException::flattenArgs() just went in so should fix the huge exception issue.
Comment #10
wim leerscatch: the huge exception was only a symptom of a deeper problem, see #5.
Comment #11
alexpottSo
editor_form_filter_admin_format_submit()was comparing apples with oranges. This meant it was calling delete on an object but then continuing to use the same object - this was fine whilst the config factory was keeping a stash of the object in the static cache but once this was removed the bug became uncovered.Comment #12
berdirHad a look at the form alter and submit, the fix is correct, but the code is pretty confusing as we have both 'editor' form values and
$form_state->get('editor'). Also getEditor() shouldn't exist, that should use id() instead. But neither of that is a problem of this issue, the fix is correct.
Fixed a small coding style issue, I think this is good to go.
Comment #13
alexpott@Berdir thanks!
I think
id()andgetEditor()methods are different.Basically what is happening here is that if the Editor configuration entity is configuring a different editor (eg. ckeditor or aloha) then the submit handler is deleting the existing editor config entity for the filter format (eg. full_html, filtered_html) you are configuring.
Comment #15
catchCommitted/pushed to 8.0.x, thanks!
Comment #17
wim leersYes, there are a lot of cases of "unfortunate naming" in
editor.module. This is because it was one of the first (if not the first) module using the Config system and an early user of the Plugin system. Since then, we added a lot more boilerplate and rules for both config entities and plugins. I'd love to improve naming, but that requires API breaks, with very little gain overall.