Currently drupal_prepare_form does:
if (!isset($form['#validate'])) {
if (function_exists($form_id . '_validate')) {
$form['#validate'] = array($form_id . '_validate');
}
}
...
if (!isset($form['#submit'])) {
if (function_exists($form_id . '_submit')) {
$form['#submit'] = array($form_id . '_submit');
}
}
So what happens in the case that $form['#validate'] or $form['#submit'] exist already? Those default handlers are not added, which is not expected behavior (see #239676: SA-CORE-2009-001: Missing validation for hook_user which will be fixed by this issue).
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | drupal.form-default-handlers.22.patch | 2.25 KB | sun |
| #21 | drupal.form-default-handlers.21.patch | 1.38 KB | sun |
| #20 | drupal.form-default-handlers.patch | 1.23 KB | sun |
| #18 | 361702.patch | 1.96 KB | jody lynn |
| #15 | 361702-fapi-drupal-process-form-D7.patch | 1.87 KB | dave reid |
Comments
Comment #1
dave reidPatch ready for review.
Comment #2
dave reidComment #4
dave reidVery interesting... looking into the failure.
Comment #5
jhedstromSubscribing.
Comment #6
dave reidRequesting retest.
Comment #8
dave reidRerolled and retesting.
Comment #10
jody lynnThe test failure was correctly identifying an issue in taxonomy module related to submit function handling.
There was trouble in how taxonomy vocabulary deletion was calling the submit function in the confirm delete form (the confirm delete submit function was competing with the submit function of the vocabulary edit form itself). I moved the call to mirror how taxonomy term deletion is already coded. Not sure if this should be a new issue.
Comment #11
jody lynnComment #12
cburschkaRelevant to drupal_prepare_form()? This patch isn't what it says on the tin.
Comment #13
wickedskaman commentedIs this still being ported to D6 or has this happened already?
Comment #14
dave reidRe-rolled just with the basic part. Want to see how much is still broken with taxonomy.module.
@wickedskaman: It's still in progress for D7, and needs to be backported.
Comment #15
dave reidComment #17
wickedskaman commentedThank you for the prompt reply. I have spent a couple thankless hours troubleshooting a system settings form not realizing it's an honest to goodness bug. Waah waaaah. Thanks again.
Comment #18
jody lynnRe submit.
Comment #20
sunThe usage of array_unshift() limits the possible use-cases without reason.
An wrapping form implementation like http://api.drupal.org/api/function/user_profile_form/7 and http://api.drupal.org/api/function/user_account_form/7 may want to invoke the #submit handler from the inner form before the #submit handler of the outer form.
That said, and looking at aforementioned wrapper, this change requires to go through all of core and remove #submit handlers... oh wait
Comment #21
sunOf course, we do not want to break existing implementations like aforementioned http://api.drupal.org/api/function/user_profile_form/7
Hence, this only needs to happen if the form handler is not contained already.
Comment #22
sunAnd why do we special case #type defaults here?
Comment #24
sunThis patch breaks http://api.drupal.org/api/function/taxonomy_form_vocabulary/7
...and therefore it potentially breaks all multistep form handling and/or all wizard-alike form builders like this example in core (which I didn't even know exists).
Hence, except for the #type fixes... this is a won't fix for me.
Comment #25
cburschkaJust stumbled over this bug again. It really is kind of nasty.
Comment #26
sunForm constructors have to be able to explicitly set #validate and #submit to an empty array, so as to explicitly disable the default callbacks, even if they exist. See node_form() for an example.
The #type clean-up from the last patch would be nice to do, but effectively is a separate issue.