Hi,

I'm using the 6.x-1.14 version of the Ajax module in a Drupal 6.20 website. I've found a problem with redirections and drupal messages. For example: when a user goes to http://example.com/user/password to request a new password, provides an email address and clicks the button, the user is correctly redirected to the http://example.com/user page, but the message "Further instructions have been sent to your e-mail address" set by the Drupal core's user module in the user_pass_submit() function is never shown to the user.

I've tried to track the problem and when the Ajax response is sent back to the browser, the Drupal.Ajax.response function is called, and the "// Redirect else{...}" section is executed. In this section, the "Drupal.Ajax.invoke('complete', data)" returns FALSE, so the redirect is executed but the "Further instructions have been sent to your e-mail address" message is lost and never shown to the user.

I think this is a bug in the Ajax module. Any ideas about how to get these messages shown to the user?. Any help will be more than welcome. Thanks in advance.

Comments

GoddamnNoise’s picture

StatusFileSize
new1.55 KB

Hi again,

I've made a patch to solve this problem. This patch includes the patch http://drupal.org/files/issues/ajax_module_redirect_2.patch (comment #21 at http://drupal.org/node/413242) too. I hope it will help anybody facing the same problem. Could any of the Ajax module maintainers test the patch and provide feedback?. Thanks in advance.

igorik’s picture

Status: Active » Needs review

subscribe

Aleksey Zubko’s picture

StatusFileSize
new1.02 KB

@GoddamnNoise
Thank for patch, but in my case this patch make wrong redirect ($data['redirect'] == '//' and I don't known why )).
My patch work fine for me.

GoddamnNoise’s picture

It works like a champ for me, maybe you've installed another patch which is making the difference.

Aleksey Zubko’s picture

maybe in my site other module made this broken redirect

GoddamnNoise’s picture

Yeah, i think that could be the problem!

j_ten_man’s picture

Does not work if you have destination in the query string as it is handled in a different place but the messages are lost. Changed (in the patch from #3)

  $messages = drupal_get_messages(NULL, empty($data['redirect']));

to

  $messages = drupal_get_messages(NULL, empty($data['redirect']) && empty($_GET['destination']));
dep85’s picture

Hello, patch from #3 works fine, but not for login and registration form.
When I go through registration i can't see any message 'email was sent' or after login 'Login successful'. Maybe somebody figured out and fix that problem? I changed patch according to #7 as well ,but it doesn't work any way.

brendoncrawford’s picture

Status: Needs review » Postponed (maintainer needs more info)

Is there a reviewed working patch that I should apply here?

botanic_spark’s picture

I also have problem with login and register form. Can somebody please help?

chezwel’s picture

Also having the issue with the registration and login form deleting user messages on redirect.

arski’s picture

I have this on a custom form too.. if I set $form_state['redirect'] to something meaningful, the messages I set in the submit hook never get displayed on the redirected page.. If I don't set the redirect, they get displayed by AJAX, so.. not sure what's going on there, but it's not nice :(

arski’s picture

Status: Postponed (maintainer needs more info) » Needs work

The patch almost fixes it for me, though it does not address the same issue in ajax_validator - if any messages are set during some validate function, they're still lost for me.. I just solved this for me by setting the 2nd parameter to FALSE, but that's obviously not perfect.

nor4a’s picture

I had the same problem - but not using AJAX module.

The solution for it is to add a record to the users table with ID 0!
The user with ID 0 seams to be important thing in the Drupal 6 system!