Problem/Motivation

Other Text editors than CKeditor do not have drupalExternalPlugins array key, which is tested by Insert module. This is causing following warning message: Notice: Undefined index: drupalExternalPlugins in insert_editor_js_settings_alter() (line 830 of modules/contrib/insert/insert.module).

Steps to reproduce

In my case I was testing Test editor: Editor.md, but it seems that others have also similar problem:
Ace Code Editor https://www.drupal.org/project/ace_editor/issues/3030411
Gutenberg https://www.drupal.org/project/gutenberg/issues/3058842
When selected Editor.md, then on the field settings (type Text (formatted, long)) warning message is displayed.

Proposed resolution

In function insert_editor_js_settings_alter() test if this key exists :

    if (isset($settings['editor']['formats'][$text_format_id]['editorSettings']['drupalExternalPlugins']) && !in_array(
      'drupalimage',
      array_keys($settings['editor']['formats'][$text_format_id]['editorSettings']['drupalExternalPlugins'])
    )) {

Remaining tasks

User interface changes

API changes

Data model changes

Comments

Bohus Ulrych created an issue. See original summary.

neslee canil pinto’s picture

Version: 8.x-2.0-beta2 » 8.x-2.x-dev
Status: Active » Fixed

@Bohus Ulrych this issue is fixed in #3103930: in_array() expects parameter 2 to be array, will make a new release soon

Status: Fixed » Closed (fixed)

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

bohus ulrych’s picture

Hi again, maybe it is related, but not same.
In #3103930 is introduced new validation for
$settings['editor']['formats'][$text_format_id]['editorSettings']
but my error is little bit different, and it is fixed with this validation
$settings['editor']['formats'][$text_format_id]['editorSettings']['drupalExternalPlugins']
Thanks

promo-il’s picture

8.x-2.x-dev updated 24 May 2021 (Drupal Version: 8.9.15, PHP:7.2)

Notice: Undefined index: drupalExternalPlugins in insert_editor_js_settings_alter() (line 833 of modules/~media/insert/insert.module).
insert_editor_js_settings_alter(Array, NULL, NULL) (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('editor_js_settings', Array) (Line: 88)
Drupal\editor\Plugin\EditorManager->getAttachments(Array) (Line: 100)
...
Warning: array_keys() expects parameter 1 to be array, null given in insert_editor_js_settings_alter() (line 833 of modules/~media/insert/insert.module).
insert_editor_js_settings_alter(Array, NULL, NULL) (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('editor_js_settings', Array) (Line: 88)
Drupal\editor\Plugin\EditorManager->getAttachments(Array) (Line: 100)
...
Warning: in_array() expects parameter 2 to be array, null given in insert_editor_js_settings_alter() (line 833 of modules/~media/insert/insert.module).
insert_editor_js_settings_alter(Array, NULL, NULL) (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('editor_js_settings', Array) (Line: 88)