Deprecated PHP code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
andrew_dunn
Forum Newbie
Posts: 2
Joined: Wed Jun 17, 2009 8:41 pm

Deprecated PHP code

Post by andrew_dunn »

I'm debugging a Facebook application, and I get the following error message:

Warning: Call-time pass-by-reference has been deprecated in /usr/www/users/adminclt/fb/fbapp/facebook/classes/app.class.php on line 24

I've been trying to figure it out, but I can't seem to. Line 24 of the file is line 6 here.

Here's the relevant code:

Code: Select all

function __construct($facebook=NULL,$isAjax=false) {
            // initialize class
            require_once (PATH_CORE.'/classes/db.class.php');
            $this->db=new cloudDatabase();
            require_once (PATH_CORE.'/classes/systemStatus.class.php');
            $this->ssObj=new systemStatus($this->db);
            $this->ssObj->getProperties(&$this);
            if (!is_null($facebook))
                $this->facebook=&$facebook; // must do before setupTemplates();
            require_once (PATH_FACEBOOK.'/classes/session.class.php');
            $this->session=new session($this);              
            $this->isAjax=$isAjax;
            if (!$isAjax) {
                $this->session->setupSession();
            } else {
                // to do - setup session via jscript rather than POST
            } 
        }   
Thanks in advance!
User avatar
jgadrow
Forum Newbie
Posts: 22
Joined: Wed Jun 17, 2009 7:56 pm
Location: Cincinnati, Ohio
Contact:

Re: Deprecated PHP code

Post by jgadrow »

You're working with a 5.3 Release Candidate I take it. From their upgrade notes, the relevant line is here:

Code: Select all

58  - The behaviour of functions with by-reference parameters called by value has
59  changed. Where previously the function would accept the by-value argument, a
60  warning is now emitted and all by-ref parameters are set to NULL.
You may want to read the full document.

Basically, the function is defined as accepting a reference yet you are passing it by value. So, you will need to prefix it the variable with an ampersand to remove the deprecated warning.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Deprecated PHP code

Post by requinix »

Certified, eh?
Well, what you say is the opposite of what I see happening.


Line 24 is line 7 here.

Code: Select all

$this->ssObj->getProperties(&$this);
Get rid of the &.
User avatar
jgadrow
Forum Newbie
Posts: 22
Joined: Wed Jun 17, 2009 7:56 pm
Location: Cincinnati, Ohio
Contact:

Re: Deprecated PHP code

Post by jgadrow »

The OP had designated line 6 as being line 24... I'm not really sure which solution is correct as I'm unable to evaluate it. However, the upgrade document specifically states it will throw a warning in the case that the user provides a by-value variable (ie: not prefixed with ampersand) when the function expects a variable reference.

Hopefully the OP will let us know which of these solutions managed to solve the issue.
andrew_dunn
Forum Newbie
Posts: 2
Joined: Wed Jun 17, 2009 8:41 pm

Re: Deprecated PHP code

Post by andrew_dunn »

Thanks so much, guys. Removing the & from the following line solved the problem.
Post Reply