Asked  7 Months ago    Answers:  5   Viewed   42 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.

 Answers

53

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

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

or

error_reporting(E_ALL ^ E_DEPRECATED);
Wednesday, March 31, 2021
 
Claudio
answered 7 Months ago
29

The convertErrorsToExceptions="false" configuration option only controls the conversion of E_ERROR to exceptions. A deprecation is represented as E_DEPRECATED, though.

A configuration option is missing for controlling the conversion of E_DEPRECATED to exceptions. This will be added in PHPUnit 6.2. This will not be backported to PHPUnit 4.8, the version of PHPUnit you are using, as that version has reached its end of life.

In your bootstrap script you can set PHPUnit_Framework_Error_Deprecated::$enabled = false;, though, which will disable the conversion of E_DEPRECATED to exceptions.

Wednesday, March 31, 2021
 
MoarCodePlz
answered 7 Months ago
84

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
error_reporting(E_ALL);

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

    // Logging is usually overkill during development
    log_errors(false);
}
else
{
    // You don't want to display errors on a production environment
    display_errors(false);

    // You definitely want to log any occurring
    log_errors(true);
}

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.

Thursday, June 10, 2021
 
jsuissa
answered 5 Months ago
98

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.

Tuesday, June 15, 2021
 
TheLovelySausage
answered 5 Months ago
47

Found a listing of options here

In my case it is

Dim prettyListingProperty = DTE.Properties("TextEditor", "Basic-Specific").Item("PrettyListing")
Friday, August 27, 2021
 
aphoria
answered 2 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :