• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ General Support (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

parameter changes reported as \"negative values\"

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
7 posts • Page 1 of 1

Postby permutations » Mon May 05, 2008 6:30 pm

I'm using phpFreeChat inside Drupal, but I don't think Drupal is causing this problem.

When I make a parameter change to a numerical parameter (e.g. changing the timeout to 31000), phpFreeChat reports I've passed a negative value. I know I have not because I looked at the params array being passed in.

Any time I ever change a numeric value, I get this error from phpFreeChat. Anyone know what causes it?
permutations
Member
 
Posts: 88
Joined: Thu Apr 24, 2008 1:09 pm
Top

Postby phpfreechat » Tue May 06, 2008 9:04 am

The code in pfc that tests the positive numerics is this one :
Code: Select all
    $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);
    }

I think your 31000 number is not an integer, it's probably a string ("31000"). You could try to patch the drupal code to cast the value to a numeric value.
Or you can patch the phpfreechat code to remove this code (but I cannot guarantee that it will work nice if the value is a string).
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby OldWolf » Tue May 06, 2008 11:25 am

Or easier still:
settype($variable_goes_here, "integer");
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby permutations » Wed May 07, 2008 1:09 am

Thanks. I'm sure this is it.

Calling settype() is easy, but identifying which of the dozens of parameters I need to call it for is tedious. I'm trying to think of an easy way to do this without modifying pfc. It would be easiest to modify pfc, but inelegant. :)
permutations
Member
 
Posts: 88
Joined: Thu Apr 24, 2008 1:09 pm
Top

Postby permutations » Wed May 07, 2008 2:25 am

Got it:

Code: Select all
  foreach($params as $key => $value)
  {
    if (!is_array($value)) {
     $integer_string = (preg_match("/[0-9]/", $value) && !preg_match("/[^0-9]/", $value)) ? true : false;
     if ($integer_string) {
       settype($value, "int");
     }
   }
  }

It works! No more error message. :)
Last edited by permutations on Wed May 07, 2008 2:37 am, edited 1 time in total.
permutations
Member
 
Posts: 88
Joined: Thu Apr 24, 2008 1:09 pm
Top

Postby permutations » Thu May 08, 2008 6:53 am

Unfortunately, this worked in the test file but not in the module. I just commented out the check in phpglobalconfig.class.php.
permutations
Member
 
Posts: 88
Joined: Thu Apr 24, 2008 1:09 pm
Top

Postby permutations » Mon Nov 24, 2008 3:39 pm

I was able to fix this with simpler code in a different place in the Drupal module:

Code: Select all
if (is_numeric($value))
    $params[$setting] = (int) $value;
permutations
Member
 
Posts: 88
Joined: Thu Apr 24, 2008 1:09 pm
Top


Post a reply
7 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 20 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
cron
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub