When FAPI was first introduced, developers were told to include a drupal_goto at the end of their *_submit functions. In fact, the proper technique is to return a string with the location you would use in the drupal_goto. This allows other submit functions to run, without being interrupted by a drupal_goto.

As per the updated forms docs:

The return value of the _submit function will be the target of a drupal_goto; every form is redirected after a submit. If you return nothing, the form will simply be redirected to itself after a submit. It is polite to use drupal_set_message() to explain to the user that the submission was successful.

This patch removes the drupal_gotos in the LT for the 4.7 branch. It's easy enough to recreate the patch for head, but I don't have the time right now.

I would appreciate this patch being committed because I am writng a module that depends on logintoboggan's validation and submission functions, but I can't be redirected in the middle of the process. (Keep your eyes open for "Register On Submit", a module to allow anonymous users to register and login during a node submission).

Cheers,
-Mark

Comments

hunmonk’s picture

Status: Needs review » Needs work

the patch appears to be backwards. :) also, please include the -F^f switch in your diff so that i can see which functions the patch affects.

thanks.

mfredrickson’s picture

I am all thumbs when it comes to diff. :-)

I'll get that patch rerolled pronto.

johnalbin’s picture

Status: Needs work » Needs review
StatusFileSize
new2.37 KB

I looked at the patch and (along with it being backwards) I believe it's not handling properly all the places where logintoboggan_process_login() is called.

Here's an updated patch.

I've verified that this patch allows (for example) module_form_alter() to set $form['#redirect'] for the user_register form and to successfully redirect to the proper place. Prior to this patch, loginToboggan always used variable_get('toboggan_redirect_on_register', '').

hunmonk’s picture

Status: Needs review » Needs work

i'm pretty sure you don't want to use a return in function logintoboggan_user_login_validate

also, it would be nice if this patch also applied to HEAD.

johnalbin’s picture

Status: Needs work » Needs review
StatusFileSize
new2.38 KB

You're right. I guess I got a little over zealous when removing the drupal_goto calls.

Here's the corrected patch for 4.7.0.

johnalbin’s picture

StatusFileSize
new2.36 KB

And here's the patch for HEAD.

hunmonk’s picture

Version: 4.7.x-1.x-dev » 7.x-1.x-dev
Status: Needs review » Fixed

latest patches to 4.7 and HEAD look good--applied.

thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)