Problem/Motivation

Getting WSOD on /admin/config/content/formats/manage/[format id]
and /node/add/article and /node/*/edit

Error:
TypeError: array_intersect(): Argument #1 ($array) must be of type array, string given en array_intersect() (linea 203 de /home/labagate/public_html/labagatela.org/web/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php).

Steps to reproduce

1. Migrating from drupal 7 to drupal 10.09
2. Changing text format editor from Ckeditor 5 to nothing

Comments

Augusto182 created an issue. See original summary.

Augusto182’s picture

Title: TypeError: array_intersect(): Argument #1 ($array) must be of type array, string given en array_intersect() (linea 203 de /home/labagate/public_html/labagatela.org/web/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php). » TypeError: array_intersect(): Argument #1 ($array) must be of type array, string given in array_intersect() (line 203 of .../core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php).
cilefen’s picture

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

The steps to reproduce describe a normal activity so there must be more setup needed to reproduce the bug.

Also, please provide the backtrace.

wim leers’s picture

Also, which contrib modules did you install that provide CKEditor 5 plugins? It's likely that is the root cause.

anacolautti’s picture

In case this helps anyone, we were having a similar error:

TypeError: array_intersect(): Argument #1 ($array) must be of type array, null given in array_intersect() (line 203 of        
                                           web/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php

In our case, it happened because we updated our site to Drupal 10 but the configuration remained unchanged from our Drupal 9 previous version of the site. Then, the config element of the editor had a different structure that the CKEditor5PluginManager could not iterate.

We solved it by either editing and saving the text format again at /admin/config/content/formats, or deleting the faulty text format and creating it again (where the previous solution was not possible).

wim leers’s picture

@anacolautti Could you please share the exported text format + editor config entities from both before and after the re-saving? 🙏

anacolautti’s picture

StatusFileSize
new919 bytes
new869 bytes

Hi @wim-leers. Sure, I hope this helps!

I believe this structure change

d9 settings:

settings
  toolbar
    rows 

to

d10 settings:

settings
  toolbar
    items 

is what broke my site. The error line was this one:

web/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php

if (empty(array_intersect($editor->getSettings()['toolbar']['items'], array_keys($definition->getToolbarItems())))) {
  unset($definitions[$plugin_id]);
}

and the error, that the first argument of array_intersect could not be null

wim leers’s picture

Priority: Normal » Minor
Status: Postponed (maintainer needs more info) » Active
Issue tags: -Needs steps to reproduce

Thanks, @anacolautti! Clarifying that this is no longer blocked.

Decreasing priority though because it seems very few people are running into this 😇

wim leers’s picture

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

Actually, … investigated right away, because I was too curious to find out how this could fail 🤓

Yes, you're right, d9.editor.editor.basic_html.yml is plain wrong: its settings are for CKEditor 4, not 5!

Drupal cannot have done this itself. In #5 you wrote:

We solved it by either editing and saving the text format again at /admin/config/content/formats, or deleting the faulty text format and creating it again (where the previous solution was not possible).

… that seems to have been the culprit.

In our case, it happened because we updated our site to Drupal 10 but the configuration remained unchanged from our Drupal 9 previous version of the site. Then, the config element of the editor had a different structure that the CKEditor5PluginManager could not iterate.

How did you go from Drupal 9 to 10? From which exact version to which exact version? Was https://www.drupal.org/project/ckeditor installed?

There are very explicit instructions during the update from 9 to 10. Although #3304736-43: Provide a good UX to ensure the CKEditor 4 to 5 update is always done before upgrading to Drupal 10 unless the contrib module is installed unfortunately never landed, and that would've made it more clear still 🙁 I definitely tried to convince core committers! 😅

So … I'm afraid I once again need more detail to actually be able to harden against this 🫣

catch’s picture

wim leers’s picture

wim leers’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)

Per #8 and #10.

chicodasilva’s picture

Regarding this topic, just a small update.

I had a similar error and the root cause in our project was the config for "config/sync/editor.editor.webform_default.yml".

In our case, this configuration was not updated when we updated to ckeditor5, and after migrating to Drupal 10, we were having the error in this code:

web/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php

 // Otherwise, only remove the definition if the plugin has buttons and
      // none of its buttons are active.
      elseif ($definition->hasToolbarItems()) {
        if (empty(array_intersect($editor->getSettings()['toolbar']['items'], array_keys($definition->getToolbarItems())))) {
          unset($definitions[$plugin_id]);
        }
      }
    }
granik’s picture

Just in case, I've found a workaround.
Adding these lines into settings section of editor.editor.*.yml files fixed the issue for me:

plugins: {  }
toolbar:
  items: {  }

Many thanks to @anacolautti.