Page 1 of 1

Deprecated PHP code

Posted: Wed Jun 17, 2009 8:43 pm
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!

Re: Deprecated PHP code

Posted: Wed Jun 17, 2009 9:25 pm
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.

Re: Deprecated PHP code

Posted: Wed Jun 17, 2009 9:26 pm
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 &.

Re: Deprecated PHP code

Posted: Wed Jun 17, 2009 10:11 pm
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.

Re: Deprecated PHP code

Posted: Wed Jun 17, 2009 10:44 pm
by andrew_dunn
Thanks so much, guys. Removing the & from the following line solved the problem.