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?
Comment | File | Size | Author |
---|---|---|---|
#29 | simplify-2483393-29.patch | 722 bytes | LittleCoding |
#26 | simplify-2483393.26.patch | 672 bytes | TwoD |
Comments
Comment #1
AnybodyThis may potentially be related to #2483323: Warning: Invalid argument supplied for foreach() in element_children() (Line 6517 of includes/common.inc). on user registration form (Problem with Field Collections?) because the problems appear in the same (big) project using Field Collection for example.
This error does of course NOT appear for admin users, but for users with SIMPLIFY'd UI.
Comment #2
BWPanda CreditAttribution: BWPanda commentedThanks for your issues and code fixes! I like both solutions and think that it should be fine to commit without too much testing (as making sure a form element exists before changing it seems like a sensible thing to do).
Here's a patch that adds both changes (from this issue and the other one you linked to above).
Comment #3
AnybodyThe patch equals my changes and thereby the code I have in production. RTBC from my point.
Comment #4
AnybodyPS: Thank you very much for your quick response and beautiful work. :) This is a great module!
Comment #5
steve65140 CreditAttribution: steve65140 as a volunteer commentedThe patch works fine for me.
And I echo comment #4 - this is a great module. Makes things much clearer for content authors.
Comment #6
steve65140 CreditAttribution: steve65140 as a volunteer commentedSorry but I seem to have accidentally destroyed the Issue Summary. I've pasted it back.
Comment #7
BWPanda CreditAttribution: BWPanda commentedComment #9
BWPanda CreditAttribution: BWPanda commentedComment #10
Stephen OllmanConfirm patch at #2 resolves the issue. Great work!
Comment #11
AnybodyCool! So perhaps this will be part of the next stable release? :)
Comment #13
webservant316 CreditAttribution: webservant316 commented#2 removed the errors for me... HOWEVER, the main problem still remains.
I had been using simplify to force user to only use the default format option. However, now for some reason all my text formats are default to plain text instead of the wysiwyg format option I had selected as the default in the content field configuration.
I need to get this fixed fast on my production site :-(
Comment #14
AnybodyPlease disable simplify, clear all caches and test if the behaviour is normal.
Perhaps also have a look at https://www.drupal.org/project/better_formats.
But of course we should fix this. How is your module configured and do you still get any PHP Notices / Warnings / Errors from this module after the patch?
Did this problem occur before the patch already?
Comment #15
webservant316 CreditAttribution: webservant316 commentedok - this patch did work for me, but my TinyMCE editor was not displaying, making it look like I was defaulting to the wrong text format type. So the second problem was solved with a patch from here https://www.drupal.org/node/2477343#comment-9966239. So both patch #2 above and the patch from https://www.drupal.org/node/2477343#comment-9966239 were needed to solve the problem.
The two patches effect lines of code VERY near each other. The patch at https://www.drupal.org/node/2477343 simply changes one line in simplify.module.
Seems like these two patches ought to be reviewed and committed together.
Comment #16
BWPanda CreditAttribution: BWPanda commentedThe patch from this issue has already been committed. The other issue needs further testing before I'm happy to commit it too. Please leave further discussion for the other issue as this one is fixed.
Comment #17
CD CreditAttribution: CD commentedI know that the patch from this issue has already been committed. But I'm going to wait until the next recommended release comes out because my drupal skills are not the best.
I wanted to ask though, are there any security issues with the clash with wysiwyg and getting in the log report these errors:
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).
So the question is is there a security issue here, and can someone use this to hack my site?
Thanks
Comment #18
BWPanda CreditAttribution: BWPanda commentedNo security issue, just WYSIWYG looking for something that didn't exist - you're safe.
Comment #19
AnybodyThe patch works great. Anyway I eventually have a follow-up.
When I visit the user registration page now I get the following Warning:
Here's the backtrace:
#0 element_children() called at [sites/all/modules/contrib/simplify/simplify.module:661]
#1 simplify_hide_text_format_elements() called at [sites/all/modules/contrib/simplify/simplify.module:663]
#2 simplify_hide_text_format_elements(Array ([administer_users] => Array ([#type] => value,[#value] => ),[#user] => stdClass Object ([uid] => 0 ...
...
drupal_build_form
drupal_get_form(user_register_form)
call_user_func_array(drupal_get_form, Array ([0] => user_register_form)) called...
menu_execute_active_handler() called ...
$elements is NULL in element_children().
I've got no idea yet, why this happens...
Comment #20
BWPanda CreditAttribution: BWPanda commentedThat sounds like a separate issue. Can you create a new issue for that please?
Comment #22
ggevalt CreditAttribution: ggevalt as a volunteer commentedActually, I don't think it's fixed.
I attached the patch just fine.
I uninstalled the first module. Cleared out the folder. Uploaded the new/patched folder with modules. And I get the same warning messages.
This module was working several months ago. I'm working on a dev site so I'm not sure what, on my end, might be contributing to this, but I am flummoxed. Sure would like to solve this.
Here's the message I get:
Notice: Undefined index: format in wysiwyg_pre_render_text_format() (line 222 of .... /sites/all/modules/wysiwyg/wysiwyg.module) Repeats for lines 224 three times, 225 and 268.
Help is always appreciated. And thanks for all your hard work. Sorry it isn't helping me. :)
g
Comment #23
LittleCodingI've just bumped into the same error message when creating an admin form. The fix I found was to check for each format, guidelines, help and limit access for each. Well that is you goal is to hide all three (format - "Text format" [drop down selector], guidelines - "Text Formatter Details" [like limits of markup and filter tips], help - "more information about text formats").
Sorry I do not have time to make up and submit the patch.
Comment #24
zeezhao CreditAttribution: zeezhao commentedHi. Seeing this issue too. Setting to open.
Comment #25
joshuautley CreditAttribution: joshuautley commentedPatch #2 worked for us. Thank you.
Comment #26
TwoDEncountered the original issue when debugging #2243413-21: Error when adding field items - Add another item and I'm glad to see that part fixed already.
Rolled a patch for the additional changes in #23.
Comment #27
NWOM CreditAttribution: NWOM commented#26 worked great. Thank you!
Comment #28
Tharick CreditAttribution: Tharick commented#26 working cool. Thank you :)
Comment #29
LittleCodingA minor change to the patch in #26 to individually remove access to the format elements.
Comment #30
Dom. CreditAttribution: Dom. as a volunteer commentedPatch 29 is RTBC
Comment #31
BWPanda CreditAttribution: BWPanda commentedThere seems to be two different solutions to hiding the text format element happening here in the issue queues. #2477343: TinyMCE editor hidden on upgrade solves the problem by simply adding CSS to hide the text format element (rather than this solution which disables access to it). I suspect the CSS solution is the better option as other issues seem to revolve around the fact that disabling access to form elements can muck up other modules that require them.
So please test the patch #2477343: TinyMCE editor hidden on upgrade instead and let's see if that solves a few different issues at once.
Comment #32
jelo CreditAttribution: jelo commentedI just tested the patch in the other issue and it solved my issue as well...
Comment #33
Dom. CreditAttribution: Dom. as a volunteer commentedVersion 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.