I am working on a site where phpfreechat is enabled. I came to see that no messages were being shown to the end user. After searching through the code I found that phpfreechat was unsetting the SESSION['messages'] variable. I disabled the phpfreechat module and everything went back to normal. Is this the designed behaviour of phpfreechat? Is there a suggested approach to take care of this issue?

Thanks for your time.

Comments

anoopjohn’s picture

I have more information about this issue.

In phpfreechat.module the drupal session messages were being unset.

if ($messages = drupal_set_message()) {
  unset($_SESSION['messages']);

}

The messages are being unset here and it is not being set anywhere. I fixed this for my site by changing this to

global $message_queue_hack; 
if ($messages = drupal_set_message()) {
  $message_queue_hack = $_SESSION['messages'] ;

  unset($_SESSION['messages']);

}

and then adding a THEMENAME_preprocess_page() function to my theme's template.php. Replace THEMENAME with your themename

function mmea_preprocess_page(&$variables) {
  global $message_queue_hack;
  $messages = $message_queue_hack;
  // Iterate through the list of messages stored from phpchat
  reset($messages);
  while (list($type, $type_messages) = each($messages)) {
    reset($messages[$type]);
    while (list($key, $message) = each($messages[$type]))
    {
      // If a message has phpchat in it then remove that message
      if (strstr($message, 'phpFreeChat')) {
        array_splice($messages[$type], $key, 1);
      }
      //echo $key .':'. $message .'<br />';
      //echo $messages[$type][$key] .'<br />';
    }
  }
  // Put the messages back in session and allow theming function 
  // to process it and generate HTML
  $_SESSION['messages'] = $messages;
  $variables['messages'] = theme('status_messages');
  // unset the system messages queue again
  unset($_SESSION['messages']);
}

Why would phpfreechat want to unset Session messages?

permutations’s picture

I added the hack to reset the messages because of a bug I encountered. It was with the Drupal 5 version of the module - perhaps this bug was fixed in Drupal 6. I forgot it was in there.

sja1’s picture

Priority: Normal » Critical

I'm having the same issue. I'd say this is a fairly serious problem given that it completely disrupts a crucial core functionality.

Permutations, can you check easily whether the bug you encountered y the D5 version has gone away in D6? Can we just remove without any problems the code that unsets the messages? If not, so that community members can look for a better solution, can you tell us what the bug was that caused you to insert that code in the first place?

Many thanks in advance. And thanks for all the work you put into making this module.

igorik’s picture

same problem :(

igorik’s picture

I commented out all this code from module:

if ($messages = drupal_set_message()) {
  unset($_SESSION['messages']);

}

the chat is still working and messages are now showing.

anoopjohn’s picture

Issue summary: View changes
Priority: Critical » Normal
Status: Active » Fixed

This seems to be fixed in the later versions in D6 as well as D7 version of the module. I am marking this issue as fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.