Drupal Messages not being shown when module is enabled.
anoopjohn - August 14, 2009 - 03:34
| Project: | phpfreechat |
| Version: | 6.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
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.

#1
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?
#2
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.
#3
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.