This was a pesky bug, where our dpm() messages (drupal_set_message()) we were using for debugging a login issue were disappearing. After chasing down a bunch of red herrings, we just realized that the ajax module is obliterating messages when ajax_validator() runs. The two things I don't get are why this is running AFTER hook_user() runs, and two: why obliterate all the messages anyway? Was this intended?

/**
 * Validation handler callback
 *
 * @param $form Assoc
 * @param $form_state Assoc
 * @return Bool
 */
function ajax_validator(&$form, &$form_state) {
  if (array_key_exists('drupal_ajax', $_REQUEST)) {
   // BYE BYE MESSAGES 
    drupal_get_messages(NULL, TRUE);

    $data = ajax_build(array(
      'messages_error' => form_get_errors(),
      'form_id' => $form_state['values']['form_id'],
      'options' => $form['#ajax']
    ));
    // FAIL 
    if (!$data['status']) {
      ajax_invoke_validate_fail($form, $form_state, $data); 
      ajax_out($data);
    }
    // PASS 
    else {  
      $pass = TRUE; 
      ajax_invoke_validate_pass($form, $form_state, $data, $pass); 
      if (!$pass) {
        ajax_out($data);
      }
    }
  }
  return TRUE;
}

Comments

frankcarey’s picture

bump

saipas’s picture

Hey,

same issue here. Commenting 'drupal_get_messages' doesn't change anything.

nicoloye’s picture

same issue here too.