How to Fix the “Assigning the return value of new by reference is deprecated” Notice in Joomla

One of our clients was having a blank page when he was logging in to the backend of his Joomla website and so he turned to us for help.

We enabled error reporting and we saw the following two errors:

Deprecated: Assigning the return value of new by reference is deprecated in /libraries/openid/Auth/OpenID/Consumer.php on line 274
Deprecated: Assigning the return value of new by reference is deprecated in /libraries/openid/Auth/OpenID/Consumer.php on line 276

Obviously, lines 274 and 276 had an & (an ampersand) that needed to be removed, and so we opened the Consumer.php file and changed the following function:

    function Auth_OpenID_Consumer(&$store, $session = null, $consumer_cls = null) {
        if ($session === null) {
            $session = new Auth_Yadis_PHPSession();
        }

        $this->session =& $session;

        if ($consumer_cls !== null) {
            $this->consumer =& new $consumer_cls($store);
        } else {
            $this->consumer =& new Auth_OpenID_GenericConsumer($store);
        }
        $this->_token_key = $this->session_key_prefix . $this->_token_suffix;
    }

to this:

    function Auth_OpenID_Consumer(&$store, $session = null, $consumer_cls = null) {
        if ($session === null) {
            $session = new Auth_Yadis_PHPSession();
        }

        $this->session =& $session;

        if ($consumer_cls !== null) {
            $this->consumer = new $consumer_cls($store);
        } else {
            $this->consumer = new Auth_OpenID_GenericConsumer($store);
        }
        $this->_token_key = $this->session_key_prefix . $this->_token_suffix;
    }

(Notice that we removed the ampersands that were highlighted in red in the original function.)

After fixing the function, we uploaded the Consumer.php file but we we saw yet another error: Joomla was complaining that it wasn’t able to load the authentication libraries. After some investigation, we discovered that the reason for this is that the default Joomla authentication plugin was disabled – and so we enabled it and that fixed the problem!

Now here’s a quick but very valuable piece of information – if you are seeing an error (when logging in to Joomla’s backend) that is related to OpenID or LDAP and you know that you’re not using either of them and you are using Joomla 1.5, then here’s what you need to do:

  • Go to phpMyAdmin and select the database that contains the data of your Joomla website.
  • Run the following query:

    UPDATE jos_plugins SET `access` = 1, `ordering`=1, `published`=1 WHERE `id` = 1;

  • The above query will enable the default authentication for Joomla (which is usually what the Joomla administrator wants). Now we need to disable the rest of the authentication plugins by running the following query:

    UPDATE jos_plugins SET `published`=0 WHERE `name` LIKE `Authentication%' AND `id` != 1;

    Running the above query will ensure 2 things:

    1. There won’t be other authentication plugins that will take priority over Joomla’s default authentication.
    2. Joomla will not wait for other authentication plugins (that may connect to 3rd party servers) to run if the provided credentials are incorrect.

If you’re having problems with logging in to your Joomla’s backend and if the above did not work for you then you can always contact us. Our prices are affordable, our work is super fast, our quality is professional, and we are very friendly to work with.

6 Responses to “How to Fix the “Assigning the return value of new by reference is deprecated” Notice in Joomla”
  1. Comment by Julian — February 26, 2013 @ 6:05 pm

    the first sql worked but for the second sql UPDATE jos_plugins SET `published`=0 WHERE `name` LIKE `Authentication%’ AND `id` != 1;

    i get error – {“success”:false,”error”:”
    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘id` !=1’ at line 1″}

  2. Comment by Fadi — February 26, 2013 @ 6:53 pm

    Hi Julian,

    Please try:

    UPDATE jos_plugins SET `published`=0 WHERE `name` LIKE 'Authentication%' AND `id` 1;

  3. Comment by Charley Hankins — October 24, 2013 @ 5:28 pm

    Hi! I was encountering the white screen of death after logging in to the admin section of the website.

    I tried your solution listed above:

    UPDATE jos_plugins SET `access` = 1, `ordering`=1, `published`=1 WHERE `id` = 1;

    Worked fine.

    The second part:
    UPDATE jos_plugins SET `published`=0 WHERE `name` LIKE `Authentication%' AND `id` != 1;

    Returned an error:
    ERROR: Unclosed quote @ 80
    STR: `
    SQL: UPDATE cwh_plugins SET `published`=0 WHERE `name` LIKE `Authentication%’ AND `id` != 1;

    SQL query:

    UPDATE cwh_plugins SET `published`=0 WHERE `name` LIKE `Authentication%’ AND `id` != 1;

    MySQL said: Documentation
    #1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘id` != 1’ at line 1

    When I attempt to log in to the admin section I am returned with the following error:

    JAuthentication::__construct: Could not load authentication libraries.
    JFolder::create: Could not create directory
    Username and password do not match

    Please advise.
    Thanks,
    CH

  4. Comment by Fadi — October 24, 2013 @ 5:33 pm

    Hi CH,

    Please try:

    UPDATE jos_plugins SET `published`=0 WHERE `name` LIKE 'Authentication%' AND `id` != 1;

    (The type of quote before Authentication is different – This is a display issue with the CMS).

  5. Comment by Charley Hankins — October 29, 2013 @ 5:08 pm

    Thanks, but no dice.

    SQL returned: Affected rows: 0 (Query took 0.0006 sec)

    Upon attempting to log in to the administration section, I am returned with the following error:

    JAuthentication::__construct: Could not load authentication libraries.
    JFolder::create: Could not create directory
    Username and password do not match

  6. Comment by Fadi — October 29, 2013 @ 5:25 pm

    Hi Charley,

    Which version of Joomla do you have? This post only applies to Joomla 1.5.

Leave a comment