After an update to actual Versions of phpfreechat module and phpfreechat itself, reactivating the "Who's chatting" block results in a blank frontpage.
I found a solution in the forums for that, but a user list wont show up.

I tried to track the problem down myself, but my Kung Fu isn't strong enough. ;)
Seems to be just a problem of changed file structure in the phpfreechat cache dirs.

Aircat

Comments

RaRi’s picture

Same here - but on 5.x-1.x-rc4.

wngreen’s picture

For debugging I put:

      $info  = new pfcInfo(md5($base_url), $params['data_private_path']);
      $errors = $info->getErrors();
      if (count($errors))
      {
        foreach($errors as $e)
            $block['content'] .= $e;
        return $block;
      }

and got the error message:
_Error: the cached config file doesn't exists_

RaRi’s picture

By the way .. it does not really make sense to work with phpfreechat if you do not get the "who is chatting" block.

Rocket-Man’s picture

Version: 5.x-1.x-dev » 5.x-1.0-rc4

Hi there,

I found the error. Take a look at the file "phpfreechat.module", line 331.
Here it says:
$params['serverid'] = md5('node'. $node->nid);

A md5 string is build using "node" + node-id, to identify the chat. But when it comes to get the users from the chat another md5 string (based on the host-name) is build. Take a look at line 234.
$info = new pfcInfo(md5($base_url), $params['data_private_path']);

So I removed the line 331 and the block showed the users in the chat :-)

Happy Chatting,
Rocket-Man

aircat’s picture

Great work Rocket-Man!

I owe you a beer ... i mean, just update your Excel-Sheet with my beer depts! ;)

Thank you
Aircat

Vallenwood’s picture

Rocket-Man set me on the right path, but his solution had some vague language, and didn't work for me. Here's what did:

In phpfreechat.module,v 1.5.2.19, on line 234, is the line Rocket-Man noticed:

$info = new pfcInfo(md5($base_url), $params['data_private_path']);

Try removing the md5 call so it becomes:

$info = new pfcInfo($base_url, $params['data_private_path']);

This may or may not work for you! If not, try the second solution I found, which is the only one which seems to CONSISTENTLY work on my site. My chat is attached to a page node, and I had to HARD-CODE that node id into the module code. As Rocket-Man points out, on line 331 you see:

$params['serverid'] = md5('node'. $node->nid);

which shows that the plugin basically "assigns" an ID to your chat based on the ID of the node it's embedded into, so the only bulletproof way I found was to hard-code it into the block on line 234:

$info = new pfcInfo(md5('node123'), $params['data_private_path']);

where "123" is replaced with the actual node ID of the node containing the chat.

I also found that I was getting a busted function call when trying to use a block. It seems the include file which contains the function _phpfreechat_check_install() was not being successfully called. So at my line 207, after global $user, $base_url;, I inserted:

include_once(drupal_get_path('module', 'phpfreechat') .'/phpfreechat.inc');

This fixed it.

The combination of these two fixes made my block work. It now shows "Who's Chatting" successfully!

permutations’s picture

I may be wrong about this - seems so obvious - but I think the reason this (and other parts of phpfreechat) are failing is that the Drupal module is not writing its data to the MySQL database. I looked and the table is empty. nid (node ID) is a field from that table.

The other fields that are supposed to be stored in the table also are not correctly saved and applied - title and channels. Have you tried to set default channels that load when you load phpfreechat? You can't do it - the channels you enter are ignored, as are the node titles.

Seems to me that something so obvious would be caught - wouldn't a database failure kick up an error? - but it's definite that the table is empty, and it's definite that these values aren't available to phpfreechat.

permutations’s picture

Title: Block "Who is chatting" not working » data not saved to database - that's the problem

I'm going to open up a new ticket for this because it's a broader issue than what's being discussed here.

I don't see a problem with using MD5 on different variables. The two instances described above are apples and oranges - I don't see a conflict.

I think the reason that hardcoding the node ID works (if it works - haven't tried it) isn't because it allows the node to be identified, but because it allows MD5 to generate a unique ID. Otherwise, you pass the string 'node' and an empty $nid field - not unique.

Some data is stored on the server hard disk, but not the channel, title, or nid - these fields are supposed to be stored in the MySQL database table, but they are not. The table remains empty. That's why it ignores the default channels and titles you specify.

The INSERT command is called within a nodeapi hook. Perhaps the hook is never being called for some reason. I'm not an expert in Drupal modules, so I can't say. I want to open a bug report on this so someone who is knowledgeable can look.

I think that if the data were properly stored, all the lingering problems with phpfreechat (except for the scrolling in IE7) would go away. You'd see the chat blocks, default channels and titles would be saved, etc.

permutations’s picture

Title: data not saved to database - that's the problem » phpfreechat blocks not working properly

I didn't mean to change the issue title with my last comment, so I'm posting another comment.

It's true the Drupal database table phpfreechat isn't used, but I discovered that the phpfreechat data is stored in the variables table. I don't know what the phpfreechat table is for (perhaps only for the MySQL container?) and I don't know if this is actually a bug or the cause of the block problem.

None of the solutions posted here worked for me. I'm still trying to understand what the code does so I can fix it. I wish someone who is more familiar with the code than I am would take a look!

permutations’s picture

I have fixed this problem - code posted here:

Blocks bug:
http://drupal.org/node/200962

I also fixed the database problem - you have to fix this first because the blocks fix uses the database:

Database bug:
http://drupal.org/node/250069

It's correct that the server is based on the node ID and not the URL, but to get the node ID you have to make a database call - that is, there has to be something in the database (which wasn't being written). The node is not known in this function, so just changing to the variable name won't work. Hardcoding the node ID will work, but it kludgy. The code I posted works.

The solution to the scrolling problem is posted here:

Scrolling bug in IE 7:
http://drupal.org/node/225162

permutations’s picture

I fixed all the bugs in the phpfreechat module (a few more than are listed above), updated the module version to 5.x-1.1, and posted the full package on my Web site here:

http://permutations.com/drupal/phpfreechat.php

I emailed the original author of the module about creating a new download, but he never answered me. There were too many changes to track of as individual patches.

owahab’s picture

Status: Active » Closed (duplicate)
permutations’s picture

There's a new version with two additional fixes on my Web site (along with many other fixes):

http://permutations.com/drupal/phpfreechat.php

permutations’s picture

I just uploaded a new version (http://permutations.com/drupal/phpfreechat.php).

I backed out setting the default timeout to 35000 in the module. It's not working because the "negative number" error is still happening after clearing the cache (/rehash). The timeout needs to be changed to avoid disconnects, and the easiest way to do this is to change it directly in pfcglobalconfig.class.php. phpFreeChat has an integer check in there, and Drupal's form API doesn't have an integer type. I tried to identify the integer strings and change them and it worked in a test file, but not in the module.

pfcglobalconfig.class.php is in the phpFreeChat src directory (it's not a module file).

  1. To change the default timeout, find this variable assignment and change the 20000 to 35000:

    var $timeout = 35000;
    
  2. To get rid of the negative number error, comment out this code in pfcglobalconfig.class.php:

    /*	
        $numerical_positive_params = $this->_params_type["positivenumeric"];
        foreach( $numerical_positive_params as $npp )
        {
          if (!is_int($this->$npp) || $this->$npp < 0)
            $this->errors[] = _pfc("'%s' parameter must be a positive number", $npp);
        }
    */	
    
ekrispin’s picture

subscribing