Problem/Motivation

When upgrading to Drupal 9.4.4 the database upgrade script crashes with the following error:

Error: Call to a member function filters() on null in Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalImageCaption->isEnabled() (line 111 of /var/www/drupal/core/modules/ckeditor/src/Plugin/CKEditorPlugin/DrupalImageCaption.php)

#0 /var/www/drupal/core/modules/ckeditor/ckeditor.module(159): Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalImageCaption->isEnabled()
#1 /var/www/drupal/core/modules/ckeditor/ckeditor.post_update.php(22): _ckeditor_get_enabled_plugins()
#2 [internal function]: {closure}()
#3 /var/www/drupal/core/lib/Drupal/Core/Config/Entity/ConfigEntityUpdater.php(128): call_user_func()
#4 /var/www/drupal/core/modules/ckeditor/ckeditor.post_update.php(40): Drupal\Core\Config\Entity\ConfigEntityUpdater->update()
#5 /var/www/drupal/core/includes/update.inc(295): ckeditor_post_update_omit_settings_for_disabled_plugins()
#6 /var/www/drupal/core/includes/batch.inc(295): update_invoke_post_update()
#7 /var/www/drupal/core/includes/batch.inc(137): _batch_process()
#8 /var/www/drupal/core/includes/batch.inc(93): _batch_do()
#9 /var/www/drupal/core/modules/system/src/Controller/DbUpdateController.php(186): _batch_page()
#10 [internal function]: Drupal\system\Controller\DbUpdateController->handle()
#11 /var/www/drupal/core/lib/Drupal/Core/Update/UpdateKernel.php(115): call_user_func_array()
#12 /var/www/drupal/core/lib/Drupal/Core/Update/UpdateKernel.php(76): Drupal\Core\Update\UpdateKernel->handleRaw()
#13 /var/www/drupal/update.php(27): Drupal\Core\Update\UpdateKernel->handle()
#14 {main}

Chose critical as the update can't be performed. It also blocks other updates. But your mileage may vary :)

Steps to reproduce

Run composer to upgrade the site to Drupal 9.4.4.
Follow the instructions and run the update script

The above error message is generated and the update script is aborted. Next time the script is run the same crash occurs.

Proposed resolution

None yet

Remaining tasks

-

User interface changes

-

API changes

-

Data model changes

-

Release notes snippet

-

Comments

sl27257 created an issue. See original summary.

cilefen’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

This indicates filter_align or filter_caption, or both, do not exist. These ship with the module. Do you have any idea how they are not present on the affected Drupal instance?

sl27257’s picture

Status: Postponed (maintainer needs more info) » Active

The filter ***seems*** to be there when checking using the devel module.

It looks more like something is broken in the database. The site as such has a long history, I think it started as 4.x.x or something. And the upgrade from D7 to D8 was a nightmare, so it could very well be something that is broken in the database.

The fail seem to be here in the Editor entity definition i getFilterFormat():

$this->filterFormat = \Drupal::entityTypeManager()->getStorage('filter_format')->load($this->format);

For a certain instance there is a "format" (=1) but it can't be loaded.

Will continue to check after refreshing how the entities are stored!

cilefen’s picture

Status: Active » Postponed (maintainer needs more info)

Alright, this is postponed pending information.

sl27257’s picture

Hmmm,

the following seems to be the case:

The config item editor.editor.1 points to filter.format.1
The config item editor.editor.3 points to filter.format.3

The filter formats are however called filter.format.basic_html, filter.format.full_html, filter.format.plain_text in my implementation. So this is why it breaks.

Interesting... I have no clue why it is like this. I have a faint memory of that the upgrade from D7 to D8 had some issues with the filters.

sl27257’s picture

I have one idea for what has happened. I have not had time to verify (i.e. confirming it in the code). And that is that somehow my filters have had the entity name "full_html" etc instead of a running number "1". When one of the plugs were introduced it took for granted that all filter had running number as their entity id instead of as in my case the name.

The work around in my case was to do the following in the "devel module" "config editor":

For the config items editor.editor.1 and editor.editor.3 (the items in question are dependent on YOUR specific configuration!) change the config key "config" from "filter.format.1" to "filter.format.full_html" and also "format" from "1" to "full_html". The same was done for editor.editor.3 with the same items.

With that I was able to run the update without any crashes. It also seems like my Drupal instance is working afterwards.

Whether this is a regression problem from the D7 to D8 update is hard to tell. If I get time I will study the code to see if it is a generic problem or just a problem in my implementation. Anyhow the "full_html" etc seems to be the normal entity id.

quietone’s picture

Project: Drupal core » CKEditor 4 - WYSIWYG HTML editor
Version: 9.4.x-dev » 1.0.x-dev
Component: ckeditor.module » Code

CKEditor has been removed from core, CKEditor 4 is removed from Drupal Core in 10.0.0

EricCad’s picture

I have the same issue with Drupal 9.4.5 when I use drush updatedb
I have CkEditor4 1.0.1 Stable release, released 12 September 2022

EricCad’s picture

I can do "drush updatedb" applying the following steps:
"cd core/modules/ckeditor"
then do an "ls"
and find:
ckeditor.post_update.php

"mv ckeditor.post_update.php whatever"

and then do:
"drush updatedb"

then I have put the correct name again.

tjtj’s picture

I have the same issue. Cant update to Drupal 10 until this is solved
This still occurs in 9.5.0

In ProcessBase.php line 171:

  Unable to decode output into JSON: Syntax error

  Error: Call to a member function filters() on null in Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalMedia->
  isEnabled() (line 120 of /home/public_html/web/core/modules/ckeditor/src/Plugin/CKEditorPlugin/D
  rupalMedia.php).

sl27257: please give more instructions on your fix. I have the devel module installed, but where is the config editor??
Importing the configuration fails with a gazillion errors.

sl27257’s picture

  1. Go to the "config" tab for the "devel" module
  2. Make sure you have the "Config editor" selected
  3. Click the "Config editor" tab in the secondary meny at the top
  4. Expand the "Filter variables" at the top
  5. In the filter search box search for "filter.format" (Click "Filter" to the right to do the search)
  6. Now all filters show up. Edit them one by one

Good luck!

/Thomas

tjtj’s picture

Thomas,
Thanks.
But all my config keys seem to have the correct names. E.g.,

uuid: df6bc0c5-8f64-42ac-be05-ca65b875577d
langcode: en
status: true
dependencies:
  config:
    - filter.format.mailchimp_campaign
  module:
    - ckeditor
    - editor_file
third_party_settings:
  editor_file:
    status: true
    scheme: public
    directory: inline-files
    extensions: txt
format: mailchimp_campaign
editor: ckeditor
settings:
  toolbar:
    rows:
      -
singularo’s picture

I had a leftover filter from migrating/upgrading from drupal 7. drush cdel editor.editor.1 removed the old filter and then drush updb worked fine. Test this on a backup first, there may be things using the filter which might need updating first.

sl27257’s picture

#12:

Reading your original error it seems like your case is not 100% as mine. My method to solve it, unless you have fixed it already of course, would be to trace the code backwards to see why "isEnabled()" fail due to a NULL.

There might be other config items that must be fixed instead of the ones I found.

/Thomas