Viewed   67 times

Getting these errors "Deprecated: Assigning the return value of new by reference is deprecated..."

While I know what deprecated function means, but I am not very clear that what PHP does to them? Still execute them as usual? So at this point for this function, does PHP silently assign memory location for the variable or still using reference pointer?

EDIT - thanks for the answers, I asked this question because we are using adodb_lite and the library has not corrected error.



Deperecated functions still exist and you get the warning. So they work as expected. However in a future version they might disappear.

That's the same for other deprecated language features which you sometimes get notices about. It's a way to signal changes to users which have code based on an older PHP version.

Normally the deprecated features get removed after some time, but it's not predictable how long this takes. I know of at least one case where a once deprecated feature was un-deprecated later on. However, I think that's exceptional.

So if you see these warnings, update the code. Most often the PHP documentation has more information why something has been deprecated and what to do. Most often it's an improvement (e.g. in security), so you really should deal with these warnings if you care about the code.

Edit: I think it's noteworthy in this context to look for strict standards notices PHP Manual as well. They are somewhat related because these notices are useful hints for changes in the language as well.

Enabling E_STRICT during development has some benefits. STRICT messages will help you to use the latest and greatest suggested method of coding, for example warn you about using deprecated functions.

(from the PHP Manual link above)

Wednesday, November 30, 2022

I was having the exact same problem today and I also tried all of the solutions you listed. Eventually I realized that after I replaced

=& new


= new

in class-simplepie.php, I also needed to reload the modules in the dashboard. This doesn't seem to happen when you just refresh the browser page, or even hide the module and then show it again.

So I highlighted the Incoming Links module on the Dashboard and clicked Configure. I changed the RSS feed URL to anything else (, hit Submit, and it worked. Refreshed that module with no more deprecated errors from class-simplepie.php. Did the same for the Wordpress Blog module and that also worked.

The only thing I cannot figure out is how to refresh the Plugins module. It doesn't have a Configure option and I can't get it to reload like the others.

Edit: Plugins module works now as well. Just needed time to reset.

Sunday, December 25, 2022

You need to remove every mention of this function from your code and do not replace it with anything else.

get_magic_quotes_gpc() has been useless ever since PHP 5.4.0. It would tell you whether you have magic quotes switched on in the configuration or not. Magic quotes were a terrible idea and this feature was removed for security reasons (PHP developers believed in magic & superstitions and wrote unsecure code).

Most likely even you yourself do not know why you had this line of code in your project. I know I was fooled by it when I was learning PHP. The reality is you do not need it at all. This function has nothing to do with security and the concept of input sanitization is preposterous.

Instead, rely on good security guidelines.

  • Use parameterized prepared statements for interactions with the database. PHP has a very good library called PDO, which can be used with many DB drivers including MySQL.
  • If you produce output, then escape the output taking into consideration the rules of that medium. For example when outputting to HTML use htmlspecialchars() to prevent XSS.
  • Never sanitize input. There is no magical solution that would protect you against everything. Instead, you as a developer must be aware of dangers and you need to know how to protect your code.
Tuesday, August 2, 2022

First install exolnet/homebrew-deprecated

$ brew tap exolnet/homebrew-deprecated

After it install deprecated package

$ brew install php@5.6
Tuesday, October 18, 2022

If you haven't already you should read the migration guide with particular focus on Backward Incompatible Changes and Removed Extensions.

You have bigger issues than deprecation. Ignoring E_DEPRECATED will not suffice. Because of the incompatible changes there will also be other type of errors or, maybe, even worse, unexpected behaviors.

Here's a simple example:

function goto($line){
    echo $line;

This code will work fine and output 7 in PHP 5.2.x but will give you a parse error in PHP 5.3.x.

What you need to do is take each item in that guide and check your code and update where needed. To make this faster you could ignore the deprecated functionality in a first phase and just disable error reporting for E_DEPRECATED, but you can't assume that you will only get some harmless warnings when porting to another major PHP branch.

Also don't forget about your hack and fix the deprecated issues as soon as possible.


Note: I tried to answer the question from a practical point of view, so please don't tell me that ignoring warnings is bad. I know that, but I also know that time is not an infinite resource.

Tuesday, September 6, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :