Problem: any validate and submit handlers added by

Steps to reproduce:

1. enable wysiwyg_filter module. Apply WYSIWYG filter to Filtered HTML format.
2. Enable eminline module and emvideo module. Apply embedded media filter to Filtered HTML format.
3. Configure this input format. Select changes for both emfield_filter and wysiwyg_filter. Submit.
4. Changes are saved for wysiwyg_filter but not eminline filter.

Source: In filter_admin_configure(), filter module uses array_merge() to merge filter forms from distinct modules providing filters.


      $form = array_merge($form, $form_module);

This means that any common keys, e.g., #submit, #validate, declared by one module are overwritten by later modules.

Fix: use hook_form_alter() to add validate and submit handlers.

I'll post a patch.

Comments

nedjo’s picture

StatusFileSize
new1.18 KB

Patch attached.

nedjo’s picture

Status: Active » Needs review
nedjo’s picture

StatusFileSize
new1.4 KB

We can't append to the #submit array because we need to ensure this module's submit handler comes before system_settings_form_submit().

Patch updated.

duozersk’s picture

Thank you, nedjo.

Followed this thread. Indeed, the first patch was not that good - some options were saved as string variables (namely, ...valid_classes_..., ..._valid_ids_..., and ..._style_urls_...). The second patch fixes that and now the options are saved into variables as arrays (as it should have been).

Thanks
AndyB

kewlguy’s picture

subscribing

markus_petrux’s picture

Status: Needs review » Fixed

Good catch. Thanks for working on a fix, and sorry for the delay giving feedback in return.

Patch in #3 applied to CVS.

nedjo’s picture

Status: Fixed » Needs review
StatusFileSize
new881 bytes

Thanks Markus.

Now that I look at it again, I'm not sure why I didn't just use array_unshift(). It's a safe assumption that the #submit key is set, since the form would be broken without it.

Updated patch attached.

markus_petrux’s picture

Status: Needs review » Fixed

I tend to use defensive code if it doesn't add too much overhead, but true, here we can count that core itself has already appended a submit handler if not already provided originally by the form owner.

Patch applied. Thanks again!

Status: Fixed » Closed (fixed)

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