new Services_JSON deprecated

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

new Services_JSON deprecated

Postby rscales » Fri Aug 13, 2010 4:22 am

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
rscales
 
Posts: 18
Joined: Mon Sep 14, 2009 1:10 am
Location: FR

Re: new Services_JSON deprecated

Postby shannah » Fri Aug 13, 2010 10:24 am

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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: new Services_JSON deprecated

Postby rscales » Mon Aug 16, 2010 6:40 am

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
rscales
 
Posts: 18
Joined: Mon Sep 14, 2009 1:10 am
Location: FR

Re: new Services_JSON deprecated

Postby shannah » Mon Aug 16, 2010 4:01 pm

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...
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: new Services_JSON deprecated

Postby rscales » Wed Aug 18, 2010 1:37 am

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
rscales
 
Posts: 18
Joined: Mon Sep 14, 2009 1:10 am
Location: FR


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 25 guests

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