Viewed   99 times

My server is running PHP 5.3 and my WordPress install is spitting these errors out on me, causing my session_start() to break.

Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 647

Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 662

Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 669

Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 676

Deprecated: Assigning the return value of new by reference is deprecated in /home//public_html/hub/wp-settings.php on line 712

This is annoying, but I do not want to turn off on screen error reporting. How do I disable these bothersome deprecated warnings?

I am running WordPress 2.9.2.



You can do it in code by calling the following functions.

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);


error_reporting(E_ALL ^ E_DEPRECATED);
Monday, October 3, 2022

I always use something like this in a configuration file:

// Toggle this to change the setting
define('DEBUG', true);

// You want all errors to be triggered

if(DEBUG == true)
    // You're developing, so you want all errors to be shown

    // Logging is usually overkill during development
    // You don't want to display errors on a production environment

    // You definitely want to log any occurring

This allows easy toggling between debug settings. You can improve this further by checking on which server the code is running (development, test, acceptance, and production) and change your settings accordingly.

Note that no errors will be logged if error_reporting is set to 0, as cleverly remarked by Korri.

Tuesday, August 9, 2022

If you want to continue using order by random() then just declare it safe by wrapping it in Arel.sql like the deprecation warning suggests:

Model.order(Arel.sql('random()')).first # PostgreSQL
Model.order(Arel.sql('rand()')).first   # MySQL

There are lots of ways of selecting a random row and they all have advantages and disadvantages but there are times when you absolutely must use a snippet of SQL in an order by (such as when you need the order to match a Ruby array and have to get a big case when ... end expression down to the database) so using Arel.sql to get around this "attributes only" restriction is a tool we all need to know about.

Edited: The sample code is missing a closing parentheses.

Wednesday, December 7, 2022

The warning isn't about "some function" - it's about the whole of stdext. And it's not just hand-wavy, to be discontinued eventually, deprecated: it doesn't ship with 2015.

During the early 00's work was afoot to revise the C++ standard; different compiler vendors, Microsoft included, put proposals before the committee along with prototypes. So they could be tested and evaluated, Microsoft placed implementations of their proposed extensions in stdext.

Eventually the committee chose what they were going to incorporate in that revision and released a Technical Report ("TR1"). Anticipating completion before the end of 2009, this was referred to as "C++0x", and compiler vendors began implementing these features in the tr1 namespace. Finally in 2011 the standard was finalized and we got "C++11" with all its bit and pieces back in std where they belong.

According to Microsoft's proposal, the container would be std::hash_map, but the C++ committee chose to use the term unordered_map. std::map is an ordered container, stdext::hash_map, despite the name, is not.

Microsoft's compiler has been the slowest at getting full C++11 support finished, and the standards committee has since finished a second variation (C++14) and is working on a third (C++17). Microsoft is just-about finishing C++11 in VS2015 and a big chunk of C++14, with a few significant exceptions that are apparently going to be a major problem for the VS compiler (esp constexpr and template variables).

  1. Visual Studio 2015 does not provide stdext - it's gone. This is not one of those "well, it may eventually go away" cases.

  2. stdext is specific to the Microsoft family of compilers, so writing code using stdext:: anything is not portable:

  3. The standardized version of the feature you're wanting is std::unordered_map, you should use that. It's essentially the same thing.

  4. There are unresolved bugs in stdext::hash_map.

If you really have to use stdext::hash_map, silence the warning by adding


at the top of the stdafx.h I assume your project has, or in your header files before you #include <stdext/...>, or in the solution explorer:

  • Right click on your project's entry in solution explorer,
  • Select Properties,
  • Select Configuration: All Configurations,
  • Expand the C/C++ tree entry,
  • Select Preprocessor,
  • The "Preprocessor Definitions" will probably say <different options>
  • At the beginning of the "Preprocessor Definitions" entry add _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1; so it reads _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS=1;<different options>. (or whatever was there originally should follow the ;)
Monday, August 29, 2022

Found a listing of options here

In my case it is

Dim prettyListingProperty = DTE.Properties("TextEditor", "Basic-Specific").Item("PrettyListing")
Thursday, September 1, 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 :