"Warning: array_filter() expects parameter 1 to be array, null given" Warning Appears when Saving Text Format

Created on 12 November 2021, over 2 years ago
Updated 26 April 2024, 2 months ago

Problem/Motivation

As part of preparing to upgrading to Drupal 9, I am using drupal/simplemde:1.0.0-alpha4 and ionaru/easy-markdown-editor:2.15.0 with the 9a55ddf revision of the dev-3103679-8.x-2.x issue fork of Markdown and league/commonmark:1.6.6. With this combination of plugins, when I save settings for a text format, I get the following PHP notices:

Warning: array_filter() expects parameter 1 to be array, null given in Drupal\simplemde\Plugin\Editor\SimpleMDE->submitConfigurationForm() (line 155 of modules/contrib/simplemde/src/Plugin/Editor/SimpleMDE.php).
Drupal\simplemde\Plugin\Editor\SimpleMDE->submitConfigurationForm(Array, Object) (Line: 255)
editor_form_filter_admin_format_submit(Array, Object)
call_user_func_array('editor_form_filter_admin_format_submit', Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('filter_format_edit_form', Array, Object) (Line: 321)

Warning: array_keys() expects parameter 1 to be array, null given in Drupal\simplemde\Plugin\Editor\SimpleMDE->submitConfigurationForm() (line 155 of modules/contrib/simplemde/src/Plugin/Editor/SimpleMDE.php).
Drupal\simplemde\Plugin\Editor\SimpleMDE->submitConfigurationForm(Array, Object) (Line: 255)
editor_form_filter_admin_format_submit(Array, Object)
call_user_func_array('editor_form_filter_admin_format_submit', Array) (Line: 114)
Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 52)
Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('filter_format_edit_form', Array, Object) (Line: 321)

Steps to reproduce

  1. Install the noted versions of the various Markdown-related modules.
  2. Edit (or create) a text format under /admin/config/content/formats.
  3. Select "EasyMDE" as the "Text editor".
  4. Save the text format.

Proposed resolution

It looks like \Drupal\simplemde\Plugin\Editor\SimpleMDE::submitConfigurationForm() is attempting to re-arrange the settings of the form to a different layout in the stored config, but there is no 'editor' key in the form state values.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

RTBC

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States GuyPaddock

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany C-Logemann Frankfurt/M, Germany

    Successfully tested MR !1 on D10.2 / php 8.2 and array_filter() error is gone. So +1 for RTBC.

    Increased priority because the editor config cannot be saved with this bug.

Production build 0.69.0 2024