Currently in contact.module for the contact form callbacks, we have a page callback which then calls drupal_get_form. This process is not really necessary as we can just move our flood control checks into the form building code and call drupal_get_form directly from the menu.
This also removes the e-mail validation from the code in contact_personal_page because e-mail address have to be validated whenever users are registered or edited, so checking here is ridiculous.
Comment | File | Size | Author |
---|---|---|---|
#2 | 601016-contact-remove-pages-D7.patch | 7.04 KB | Dave Reid |
Comments
Comment #1
sun.
Comment #2
Dave ReidAnd here is what the patch would look like.
Comment #3
Dave ReidFixing cross-post.
Comment #4
Dries CreditAttribution: Dries commentedThis looks like a reasonable clean-up. Some quick comments.
The global $user seems unnecessary. It is not used in this function.
Ideally, the flood checking would be done in the _validate() callback. Can be done in a follow-up patch.
Comment #5
Dave ReidActually the $user global is used quite a lot in the contact_site_form builder:
I'm not sure about moving the flood checking to validation, because if it's enabled, the user would still see a form and think they could submit it, only to be stopped by validation. Definitely worth discussion an a new issue since it wouldn't change APIs.
Comment #6
andypost+1 to this patch.
Validation for flood should be done in form definition to not confusing user about his abilities.
Comment #7
andypostTested and find very good cleanup.
Comment #8
sunPlease ignore this follow-up unless you are Dries.
@Dries: hah, actually, this looks like another potential use-case for 'wrapper_callback' -- the same form used for two different locations in two different contexts, and the wrapper may be able to setup the context, so the actual form builder can handle it accordingly. Not sure whether that's doable. Just mentioning. We just don't know yet. ;)
#571086: Allow to specify a 'wrapper callback' before executing a form builder function
Comment #9
Dries CreditAttribution: Dries commentedDave, you're right. Committed!
sun, thanks for pointing that out. That helps.
Comment #10
Dave ReidAwesome. FYI the next big contact issue is #58224: Allow anonymous users access to a members personal contact form now that all these cleanups are done. Much cleaner and smaller patch will be easier to review!