Page 1 of 1

new Services_JSON deprecated

PostPosted: Fri Aug 13, 2010 4:22 am
by rscales
Hi Steve,

I have been successfully using your xataface framework for a year now and recently moved to the latest xampp version, which included phpmyadmin 5.3. As such, I needed to move to the latest xataface version as well, now using 1.2.5.

For some reason, I am now unable to launch my application. I get the following error:

Deprecated: Assigning the return value of new by reference is deprecated in C:\xampp\htdocs\my_app\conf\ApplicationDelegate.php on line 103


from my application_delegate.php file, lines 102 and 103:
Code: Select all
   import('Services/JSON.php');
   $json =& new Services_JSON();


It seems nothing has changed in terms of the JSON.php file, or the directory hierarchy between the 1.2.5 version and the older version I was using, so I am a bit stuck as to where the problem may lie.

Dataface does seem to have access to my dB, as it creates the dataface__mtimes and dataface__version tables. When I point to http://localhost/my_app in the browser.

One other data point is that the reason I reinstalled xampp was because I also moved from XP to Win7, if that could make any difference.

Any ideas?

Thanks,
Rich

Re: new Services_JSON deprecated

PostPosted: Fri Aug 13, 2010 10:24 am
by shannah
This is one of my biggest beefs with PHP 5. In the olden days (PHP 4) you needed to return by reference when using the new operator, otherwise you'd be getting a copy of the object and not the object itself.
e.g.
Code: Select all
$obj =& new MyClass();
// rather than just $obj = new MyClass();


In PHP 5 they changed the way it handles objects so that all objects are passed by reference. This is a GOOD thing. But at the same time (for some reason) they deprecated the explicit passing by reference.

This led to a problem whereby code could work properly on PHP 4 or PHP 5 but not both at the same time. So the easiest solution for a while was to just turn off the deprecation warnings and get PHP 5 to suck it up (and still do it the PHP 4 way).

Now that PHP 4 is effectively out of the picture I'm fine with just doing it the PHP 5 way.

So anytime you see something like
Code: Select all
$obj =& new MyClass();


you can change it to

Code: Select all
$obj = new MyClass();


-Steve

Re: new Services_JSON deprecated

PostPosted: Mon Aug 16, 2010 6:40 am
by rscales
Hi Steve,

Thanks a lot - that definitely solved the problem.

However, now I see a new problem, probably due to migration to 1.2.5 xataface.

I get the following notice:

Notice: Undefined variable: ENV in C:\....\test.php on line 69

$url = $ENV.DATAFACE_SITE_URL.'/index.php?-table='.$_SESSION['current_table'];

Is $ENV.DATAFACE_SITE_URL no longer valid for finding the directory path of the application location?

Thanks,
Rich

Re: new Services_JSON deprecated

PostPosted: Mon Aug 16, 2010 4:01 pm
by shannah
That looks like smarty template notation. In PHP you would use the constants:
Code: Select all
DATAFACE_SITE_URL  // the url to the site (does not include index.php)
DATAFACE_URL // url to the dataface directory
DATAFACE_SITE_HREF // the url to the site script (includes index.php)
DATAFACE_SITE_PATH  // The file path to the site.
DATAFACE_PATH // The file path to the dataface folder.



In smarty templates it would be :
Code: Select all
{$ENV.DATAFACE_SITE_URL}
etc...

Re: new Services_JSON deprecated

PostPosted: Wed Aug 18, 2010 1:37 am
by rscales
Thanks Steve, that solved it.

Not sure why $ENV.DATAFACE_SITE_URL was working in my php files in the earlier release but I've removed the $ENV now.

-Rich