When I click on a chat room I get this error:

Fatal error: Call to undefined function chatroom_chat_get_latest_msgs() in {MYPATH}

I have searched that function in the code but there isn't.

Tnx.

Comments

teodorix’s picture

I have so trables!
I search all files in chatroom directory, but this function is not present.
Pls, give a work module.
Thx

eidolon night’s picture

Same issue. I can create rooms and everything, but once I enter a chat I get this error.

sebzur’s picture

The same issue at my side..

cstachris’s picture

Same.
Blank screen when entering a chat.

cstachris’s picture

Status: Active » Needs review

This is a temporary fix and I'm just testing it now, but download the drupal 5 module.
In the chatroom.module file, grab

1. chatroom_chat_old_msg_limit function
2. chatroom_chat_get_latest_msgs function

and put them into the file of even name, chatroom.module.

Disable automatic archiving of chats and it works, otherwise you get some error message, but the chat still works.

Here are the functions in case you are too lazy to download the chat module for drupal 5.

function chatroom_chat_get_latest_msgs($chat_id, $uid, $last_msg_id = 0, $timezone = 0, $smileys = FALSE) {
  global $user;
  $msgs = array();
  $limit = chatroom_chat_old_msg_limit($chat_id, $last_msg_id);
  if (!empty($limit)) {
    $result = db_query_range("
      SELECT cm.*, u.name, col.guest_id FROM {chatroom_msg} cm
      INNER JOIN {chatroom_online_list} col ON col.session_id = cm.session_id AND col.ccid = cm.ccid
      LEFT JOIN {users} u ON u.uid = cm.uid
      WHERE cm.ccid = %d AND (
        cm.recipient = '' OR cm.session_id = '%s' OR cm.recipient IN (
          SELECT guest_id FROM {chatroom_online_list}
          WHERE session_id = '%s' OR (uid = %d AND uid > 0)
        ) OR (cm.uid = %d AND cm.uid > 0)
      )
      ORDER BY cm.cmid DESC
    ", array(
      $chat_id,
      session_id(),
      session_id(),
      $user->uid,
      $user->uid,
    ), 0, $limit);
    while ($message = db_fetch_object($result)) {
      if ($smileys) {
        $message->msg = chatroom_smileys_filter_process($message->msg);
      }
      $name = empty($message->name) ? _chatroom_variable_get('chatroom_guest_user_prefix', 'guest-') . $message->guest_id : $message->name;
      $time = gmdate(_chatroom_variable_get('chatroom_chat_date_format', '* \S\e\n\t \a\t G:i'), $message->modified + $timezone);
      $msg = array(
        'id' => (int) $message->cmid,
        'text' => stripslashes(str_replace(array("\\", '"'), array("\\\\", '\"'), $message->msg)),
        'user' => $name,
        'time' => $time,
        'recipient' => $message->recipient,
        'type' => $message->msg_type,
      );
      $msgs[] = $msg;
    }
    $msgs = array_reverse($msgs);
  }
  return $msgs;
}

and


function chatroom_chat_old_msg_limit($chat_id, $last_msg_id = 0) {
  $limit = db_result(db_query('
    SELECT cr.old_msg_count FROM {chatroom} cr
    INNER JOIN {chatroom_chat} cc ON cc.crid = cr.crid
    WHERE cc.ccid = %d
  ', $chat_id));
  $count = db_result(db_query("SELECT COUNT(*) FROM {chatroom_msg} WHERE ccid = %d AND cmid > %d", $chat_id, $last_msg_id));
  $count += db_result(db_query("SELECT COUNT(*) FROM {chatroom_msg_archive} WHERE ccid = %d AND cmid > %d", $chat_id, $last_msg_id));
  return $count > $limit ? $limit : $count;
}

cstachris’s picture

and then when you go into administer content types, chatroom, you get this warning - but it's still working.


user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE nid = 36' at line 8 query: UPDATE chatroom SET poll_freq = 5000, idle_freq = 60000, old_msg_count = 20, kicked_out_message = '', banned_message = '', WHERE nid = 36 in /var/www/html/www.domain.com/sites/all/modules/chatroom/chatroom.module on line 157.

sebzur’s picture

I've just found, that disabling messages archive enables chat to work... But, when I clik on 'Delete Chat' button, the error occurs:

Fatal error: Call to undefined function chatroom_chat_get_from_id() in /home/drupal/www/sites/all/modules/chatroom/chatroom.forms.inc on line 452

Gabrieles’s picture

To fix the issue in #6 you just need to edit chatroom.module and remove the "," at the end of line 148.

Gabrieles’s picture

I have been able to enable message archiving, and I do not have many more errors (i still need to test and see if it is actually working, though ^____-)

You need to create a new table:

CREATE TABLE `chatroom_msg_archive` (
        cmid int(11) NOT NULL,
        ccid int(11) NOT NULL,
        uid int(11) NOT NULL,
        msg_type varchar(64) NOT NULL,
        msg varchar(512) NOT NULL,
        session_id varchar(255) NOT NULL,
        recipient varchar(255) NOT NULL,
        archived int(11) NOT NULL default '0',
        modified int(11) NOT NULL default '0',
        PRIMARY KEY  (cmid),
        KEY ccid (ccid),
        KEY session_id (session_id),
        KEY recipient (recipient),
        KEY modified (modified)
      ) ENGINE MyISAM CHARSET=utf8;

then the functions to be copy&pasted in your chatroom.module are

function chatroom_chat_get_latest_msgs($chat_id, $uid, $last_msg_id = 0, $timezone = 0, $smileys = FALSE) {
  global $user;
  $msgs = array();
  $limit = chatroom_chat_old_msg_limit($chat_id, $last_msg_id);
  if (!empty($limit)) {
    $result = db_query_range("
      SELECT cm.*, u.name, col.guest_id FROM {chatroom_msg} cm
      INNER JOIN {chatroom_online_list} col ON col.sid = cm.sid AND col.ccid = cm.ccid
      LEFT JOIN {users} u ON u.uid = cm.uid
      WHERE cm.ccid = %d AND (
        cm.recipient = '' OR cm.sid = '%s' OR cm.recipient IN (
          SELECT guest_id FROM {chatroom_online_list}
          WHERE sid = '%s'
        ) OR (cm.uid = %d AND cm.uid > 0)
      )
      ORDER BY cm.cmid DESC
    ", array(
      $chat_id,
      session_id(),
      session_id(),
      $user->uid,
    ), 0, $limit);
    while ($message = db_fetch_object($result)) {
      if ($smileys) {
        $message->msg = chatroom_smileys_filter_process($message->msg);
      }
      $name = empty($message->name) ? variable_get('chatroom_guest_user_prefix', 'guest-') . $message->guest_id : $message->name;
      $time = gmdate(variable_get('chatroom_chat_date_format', '* \S\e\n\t \a\t G:i'), $message->modified + $timezone);
      $msg = array(
        'id' => (int) $message->cmid,
        'text' => stripslashes(str_replace(array("\\", '"'), array("\\\\", '\"'), $message->msg)),
        'user' => $name,
        'time' => $time,
        'recipient' => $message->recipient,
        'type' => $message->msg_type,
      );
      $msgs[] = $msg;
    }
    $msgs = array_reverse($msgs);
  }
  return $msgs;
}

function chatroom_chat_old_msg_limit($chat_id, $last_msg_id = 0) {
  $limit = db_result(db_query('
    SELECT cr.old_msg_count FROM {chatroom} cr
    INNER JOIN {chatroom_chat} cc ON cc.crid = cr.nid
    WHERE cc.ccid = %d
  ', $chat_id));
  $count = db_result(db_query("SELECT COUNT(*) FROM {chatroom_msg} WHERE ccid = %d AND cmid > %d", $chat_id, $last_msg_id));
  $count += db_result(db_query("SELECT COUNT(*) FROM {chatroom_msg_archive} WHERE ccid = %d AND cmid > %d", $chat_id, $last_msg_id));
  return $count > $limit ? $limit : $count;
}

Also, you need to modify line 639

      (cmid, ccid, uid, msg_type, msg, session_id, recipient, archived, modified)
Gabrieles’s picture

It seems that everything is working, now, at least with D6.10 and the 6.x-1.0-beta2 using the above patch (look at the thread on how to remove the chatroom.js error message).

Enjoy your new chatroom! ^_______^

2much2learn’s picture

Assigned: Unassigned » 2much2learn
Category: bug » support
Status: Needs review » Active

Did anyone find a solution to fix the message below that you get when you click on the "Delete this chat" button for the Chatroom module?

Fatal error: Call to undefined function chatroom_chat_get_from_id() in /home/drupal/www/sites/all/modules/chatroom/chatroom.forms.inc on line 452

eidolon night’s picture

The module hasn't received updates for some time now, so I don't feel bad saying that I've switched to the phpfreechat module and am quite happy. The performance overhead is a lot less and if actually works.

2much2learn’s picture

I was having problems with the phpfreechat module that is why I was checking into the chatroom one. I was able to get things worked out late yesterday with the phpfreechat module after doing some research online. phpfreechat seems to have more of the options I was looking for in a chat so I think I will stick with that for now. Thank you for your quick response! :)

Paul Natsuo Kishimoto’s picture

Title: chatroom_chat_get_latest_msgs() not found » Fatal error: Call to undefined function chatroom_chat_get_latest_msgs()
Assigned: 2much2learn » Unassigned
Category: support » bug
Priority: Critical » Normal

A few things:

The calls to chatroom_chat_get_latest_msgs need to be updated with calls to chatroom_load_messages (chatroom.module, l.819), which is newer code that accomplishes the same thing.

Paul Natsuo Kishimoto’s picture

Status: Active » Closed (duplicate)

Whoops...looks like this is actually a duplicate of #327708: Archive feature is broken.

liza’s picture

Priority: Normal » Critical

can someone please indicate how to properly patch this ----as Kishimoto said, copy and paste is not the proper answer.

Ole Martin’s picture

Please get this module to work or just remove it. No need to have useless modules where users need to be php-specialists. This is the second time I try it to work!
I use phpFreeChat instead (http://drupal.org/project/modules?text=phpfreechat)

Doku;
Old and useless: http://groups.drupal.org/node/2613
Where to began ? http://drupal.org/project/issues/chatroom
Try out WHAT?? http://chatroom.darren.oh.name/5.x-1.x-dev/
Some help here ?? http://groups.drupal.org/drupal-chat

Paul Natsuo Kishimoto’s picture

Priority: Critical » Normal

just remove it. No need to have useless modules where users need to be php-specialists

No. Even if you're not a PHP specialist, you can read the common GPL reference text, which includes:

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You are expecting "fitness for a particular purpose" when it is explicitly not promised. Use something else if you like, but don't be rude to the chatroom devs (I am not one).

Because this is a duplicate of #327708: Archive feature is broken, which has a tentative fix available, there is no point changing the status of or commenting on this issue.

Ole Martin’s picture

You should agree that when you find such an error and a solution that is in everyone's interest that the module is updated. Or is it better that new users do not get it to work and to look in frustration for a solution that is already found and could have been arranged. And not all have English as their primary language, either.
This module could be a good module Maintainer had updated it and fixed all the useless links.

And now that you have shown me a link to the solution for me, I will try to fix it. And I hope that everyone else who reads this thread will find this solution.
To the solution (if I understand you right) http://drupal.org/node/327708