The need for this task is coming when combining Global Redirect, Boost and Mailchimp module together without setting a Thank You page for mailchimp signup form to redirect to. This is actually a Drupal core's bug but due to the fact that we are in the D8 era, I believe D7 won't be fixed for this minor issue. I may be wrong though. In the meantime we could fix the problem for Mailchimp only.

Drupal's drupal_redirect_form() invokes drupal_goto() for the current_path() if a $form_state['redirect'] is not set. This works fine in most cases. but for a block form this may not play well.

When the anonymous user submits the form, a POST request is made to the server. Boost's cache is ignored and the form gets submitted successfully. Since mailchimp is not configured to redirect to a specific page, drupal redirects to the original path of the frontpage (eg. /node). Then Global Redirect redirects properly to "/". Due to Boost's cache though, the message that "An email has been sent to you..." doesn't appear.

This whole problem may be fixed using two different methods:

  • by explicitly setting $form_state['redirect'] to '' for the frontpage but to current_path() for any other page
  • by settings $form_state['no_redirect'] to TRUE
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vensires created an issue. See original summary.

vensires’s picture

This patch explicitly sets $form_state['redirect'] to '' for the frontpage but to current_path() for any other page

vensires’s picture

This patch explicitly sets $form_state['no_redirect'] to TRUE

vensires’s picture

Issue summary: View changes