Problem/Motivation

Whilst creating a new text format with the editor and ckeditor module enabled you can not configure the editor on this form due to:

Uncaught AjaxError: 
An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /system/ajax
StatusText: OK
ResponseText: 
( ! ) Fatal error: Call to a member function getFilterTypes() on a non-object in /Volumes/devdis...<omitted>...4

I guess the issue is that the filter format does not exist yet.

Proposed resolution

Fix bug.

Remaining tasks

Write patch and add test.

User interface changes

None

API changes

None

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Rajesh Ashok’s picture

Check if filter format exists, before calling the member functions related to filter format.

Rajesh Ashok’s picture

Status: Active » Needs review
vastav’s picture

#1 is working fine for me. Now i am able to add new text format with editor.

Wim Leers’s picture

Status: Needs review » Needs work

#2207777: Can not configure editor whilst creating a new text format was a duplicate of this one.

#1: thanks for working on this! :) And great to see it confirmed in #2 that this fixes the problem. But this still needs test coverage, so back to NW.

Wim Leers’s picture

Assigned: Unassigned » Wim Leers
Status: Needs work » Needs review
Issue tags: -Needs tests +Spark, +sprint
FileSize
5.19 KB
9.67 KB

This is a regression caused by #2204129: Store the filter format on the editor entity during runtime.

Test coverage added. Applied the same principle as #1, but I put it in a helper method that makes the code more legible than a if ($object) {…} test.

We did have test coverage for the generic use case at EditorAdminTest::testAddEditorToNewFormat(), but in that case there was no code trying to do things based on the associated FilterFormat. Therefore the new test coverage lives at CKEditorAdminTest::testNewFormat().

Wim Leers’s picture

The last submitted patch, 5: text_editor_new_format-2207777-1-test_only_FAIL.patch, failed testing.

Wim Leers’s picture

Gábor Hojtsy’s picture

Looks good to me, except:

+++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/CKEditorPlugin/Internal.php
@@ -285,9 +285,16 @@ protected function generateFormatTagsSetting(Editor $editor) {
+    // When no text format is associated yet, assume nothing is disallowed, so
+    // set allowedContent to true.
+    if (!$editor->hasAssociatedFilterFormat()) {
+      return TRUE;
+    }

This sounds dangerous, to allow all content by default if there was no filter?! What is the use case for this?

Wim Leers’s picture

#9: that only happens on the form to configure text formats & text editors. Even then, it only happens if you create a new text format, and before saving that text format, you already associate a text editor.

Plus, this only applies to CKEditor's own filtering. It does not affect what's rendered to end users in any way.

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

All right then. Looks good.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: text_editor_new_format-2207777-1.patch, failed testing.

Wim Leers’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
26.74 KB
981 bytes

Trivial reroll after #2030605: Expand Editor with methods introduced some very minor changes.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, conflicts after CKE 4.4 :(

Anonymous’s picture

Status: Needs work » Needs review
FileSize
27.13 KB

In Internal.php, generateAllowedContentSetting() was renamed to generateACFSettings()

Status: Needs review » Needs work

The last submitted patch, 15: text_editor_new_format-2207777-15.patch, failed testing.

Wim Leers’s picture

Status: Needs work » Needs review
FileSize
9.7 KB

#13 and #15 included the #2241235: Shortcut/ShortcutSet entity types should use cache tags patch by accident. Proper reroll.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC per #11. This only got marked NW because it didn't apply anymore after #2039163: Update CKEditor library to 4.4 landed.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed bc5bfc9 and pushed to 8.x. Thanks!

  • Commit bc5bfc9 on 8.x by alexpott:
    Issue #2207777 by Wim Leers, pjonckiere, Rajesh Ashok | alexpott: Can...
Wim Leers’s picture

Issue tags: -sprint

Status: Fixed » Closed (fixed)

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

damondt’s picture

It looks like there's a regression for this in Drupal 9. The ajax error is:

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /admin/config/content/formats/add?ajax_form=1
StatusText: OK
ResponseText: AssertionError: Cannot load the &quot;filter_format&quot; entity with NULL ID. in assert() (line 244 of /var/www/arvestbank/docroot/core/lib/Drupal/Core/Entity/EntityStorageBase.php).
amanire’s picture

I am also seeing this behavior in Drupal 8.9.13.

tejasvi.c.h’s picture

@damondt did you find any solution for this? I'm stcuk with this too.

amanire’s picture

@tejasvi.c.h If I recall correctly, you have to first add and save the text format. Then go back and edit the CKEditor config.

crutch’s picture

D9 experienced the same #23, #26 is the workaround. Reopen and change to minor?