PHP Error - Object could not be converted to int

A place for users and developers of the Xataface to discuss and receive support.

PHP Error - Object could not be converted to int

Postby seascoot » Sun Oct 21, 2012 1:05 pm

Hi Steve,

First, let me express my appreciation for making this framework available. I am still in the process of learning how to apply it properly, but it looks like it will be extremely usable and flexible.

I am attempting to work with both a clean install of SurveyBuilder and also Version 1.9 3856 from the repository. With both, I get the following PHP error:

PHP Notice: Object of class Dataface_Record could not be converted to int in L:\wamp\www\MyXatafaceDirectory\inc\functions.inc.php on line 16

I'm using WAMP on WinXP as a test environment.

The relevant function in functions.inc.php is:

Code: Select all
00000014 function getUser(){
00000015    static $user =-1;
00000016    if ($user == -1 ){
00000017       $user = Dataface_AuthenticationTool::getInstance()->getLoggedInUser();
00000018    }
00000019    return $user;
00000020
00000021 }


This is not a fatal error, so everything seems to run just fine with error reporting off. However, the errors are quickly filling my log.

Apache version 2.2.11
PHP version 5.3.0
MySQL version 5.1.36

I thought it may be related to my WAMP configuration, but when I tried a 1.3.2 3355 installation on a shared hosting provider I got the same result.

Apache version 2.2.17
PHP version 5.2.17
MySQL version 5.1.56
seascoot
 
Posts: 3
Joined: Sun Oct 21, 2012 11:52 am

Re: PHP Error - Object could not be converted to int

Postby shannah » Fri Oct 26, 2012 8:22 am

Arg.. this is not a problem with your configuration... this is a newer version of PHP being more picky in its comparisons.
Try changing
Code: Select all
if ($user == -1 ){

to
Code: Select all
if (is_int($user) and $user == -1 ){


It seems crazy to me that PHP chokes on this... it may even be a bug with PHP.... but it is an easy fix. (This was already a workaround because of issues with initializing static variables to null in some versions of PHP).
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 11 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved