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).

Created on 14 July 2023, over 1 year ago

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

🐛 Bug report
Status

Active

Version

10.0

Component
CKEditor 5 

Last updated 3 days ago

Created by

🇨🇴Colombia Augusto182

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Augusto182
  • Status changed to Postponed: needs info over 1 year ago
  • The steps to reproduce describe a normal activity so there must be more setup needed to reproduce the bug.

    Also, please provide the backtrace.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

  • 🇩🇪Germany anacolautti

    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).

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

  • 🇩🇪Germany anacolautti

    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

  • Status changed to Active over 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

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

  • Status changed to Postponed: needs info over 1 year ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    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 🫣

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Thanks, @catch, TIL.

  • Status changed to Closed: duplicate 12 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Per #8 and #10.

  • 🇵🇹Portugal chicodasilva

    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]);
            }
          }
        }
    
  • 🇦🇹Austria granik Vienna

    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.

Production build 0.71.5 2024