Multiple notices and warnings when used together with wysiwyg.module

Created on 5 May 2015, almost 10 years ago
Updated 22 July 2023, over 1 year ago

There seems to be a bigger problem in combination with wysiwyg.module (and possibly other modules). The module seems to change the array structure in form element which wysiwyg expects.

This leads to several notices and warnings for me:

  • Notice: Undefined index: format in wysiwyg_pre_render_text_format() (Zeile 194 von sites/all/modules/contrib/wysiwyg/wysiwyg.module).
  • Warning: Invalid argument supplied for foreach() in wysiwyg_pre_render_text_format() (Zeile 194 von sites/all/modules/contrib/wysiwyg/wysiwyg.module).
  • Notice: Undefined index: format in wysiwyg_pre_render_text_format() (Zeile 223 von sites/all/modules/contrib/wysiwyg/wysiwyg.module).
  • Notice: Undefined index: format in wysiwyg_pre_render_text_format() (Zeile 226 von sites/all/modules/contrib/wysiwyg/wysiwyg.module).
  • Notice: Undefined variable: format_id in wysiwyg_pre_render_text_format() (Zeile 227 von sites/all/modules/contrib/wysiwyg/wysiwyg.module).
  • Notice: Undefined index: format in wysiwyg_pre_render_text_format() (Zeile 229 von sites/all/modules/contrib/wysiwyg/wysiwyg.module).
  • Notice: Undefined index: format in wysiwyg_pre_render_text_format() (Zeile 237 von sites/all/modules/contrib/wysiwyg/wysiwyg.module).

The cause for that is in

function simplify_hide_text_format_element($element) {
$element['format']['#access'] = FALSE;

return $element;
}

This seems to create an array structure that wysiwyg does not expect as you can see from the lines above in wysiwyg module.

As a quick fix I added the following condition that only adds the #access property if the format key exists. This fixes the bug for me, but I'm not sure if the format element hiding now works properly in all conditions or if it has side effects.

That should be checked:

function simplify_hide_text_format_element($element) {
if (!empty($element['format'])) {
$element['format']['#access'] = FALSE;
}

return $element;
}

Perhaps the module maintainer has some comments on this?

🐛 Bug report
Status

Closed: outdated

Version

3.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

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.

  • 🇫🇷France Dom.

    Version 7.x is no more really supported. Just provided as is until end-of-life.
    Feel free to reopen and update if there are reason we should still invest work on this.

Production build 0.71.5 2024