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.
asked May 10, 2010 at 15:12
2
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);
Toby Allen
11k11 gold badges74 silver badges124 bronze badges
answered May 10, 2010 at 15:14
RobusRobus
8,0695 gold badges47 silver badges68 bronze badges
8
To only get those errors that cause the application to stop working, use:
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
This will stop showing notices, warnings, and deprecated errors.
answered Feb 24, 2012 at 7:38
codefreakcodefreak
6,9603 gold badges42 silver badges51 bronze badges
I needed to adapt this to
error_reporting = E_ALL & ~E_DEPRECATED
answered Aug 21, 2010 at 9:22
Simon HSimon H
20.4k14 gold badges71 silver badges129 bronze badges
You have to edit the PHP configuration file. Find the line
error_reporting = E_ALL
and replace it with:
error_reporting = E_ALL ^ E_DEPRECATED
If you don’t have access to the configuration file you can add this line to the PHP WordPress file (maybe headers.php):
error_reporting(E_ALL ^ E_DEPRECATED);
answered May 10, 2010 at 15:15
KrekerKreker
2,4383 gold badges23 silver badges27 bronze badges
1
I just faced a similar problem where a SEO plugin issued a big number of warnings making my blog disk use exceed the plan limit.
I found out that you must include the error_reporting command after the wp-settings.php require in the wp-config.php file:
require_once( ABSPATH .'wp-settings.php' );
error_reporting( E_ALL ^ ( E_NOTICE | E_WARNING | E_DEPRECATED ) );
by doing this no more warnings, notices nor deprecated lines are appended to your error log file!
Tested on WordPress 3.8 but I guess it works for every installation.
answered Mar 28, 2014 at 18:11
CamaleoCamaleo
1,18014 silver badges14 bronze badges
1
All the previous answers are correct. Since no one have hinted out how to turn off all errors in PHP, I would like to mention it here:
error_reporting(0); // Turn off warning, deprecated,
// notice everything except error
Somebody might find it useful…
answered Oct 9, 2011 at 2:44
sudipsudip
2,7811 gold badge30 silver badges41 bronze badges
0
In file wp-config.php you can find constant WP_DEBUG. Make sure it is set to false.
define('WP_DEBUG', false);
This is for WordPress 3.x.
answered Jan 24, 2013 at 13:18
AudriusAudrius
1271 silver badge2 bronze badges
0
I tend to use this method
$errorlevel=error_reporting();
$errorlevel=error_reporting($errorlevel & ~E_DEPRECATED);
In this way I do not turn off accidentally something I need
answered Feb 10, 2017 at 11:04
realteborealtebo
24k38 gold badges112 silver badges191 bronze badges
5
If PHP warnings are breaking things in WordPress, but you still want to know what the warnings are, you can disable displaying PHP errors/warnings and only send them to the log file:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
answered Jan 18 at 8:57
GavinGavin
7,5644 gold badges52 silver badges72 bronze badges
this error occur when you change your php version: it’s very simple to suppress this error message
To suppress the DEPRECATED Error message, just add below code into your index.php file:
init_set(‘display_errors’,False);
answered Dec 16, 2017 at 10:00
1
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.
asked May 10, 2010 at 15:12
2
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);
Toby Allen
11k11 gold badges74 silver badges124 bronze badges
answered May 10, 2010 at 15:14
RobusRobus
8,0695 gold badges47 silver badges68 bronze badges
8
To only get those errors that cause the application to stop working, use:
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING | E_DEPRECATED));
This will stop showing notices, warnings, and deprecated errors.
answered Feb 24, 2012 at 7:38
codefreakcodefreak
6,9603 gold badges42 silver badges51 bronze badges
I needed to adapt this to
error_reporting = E_ALL & ~E_DEPRECATED
answered Aug 21, 2010 at 9:22
Simon HSimon H
20.4k14 gold badges71 silver badges129 bronze badges
You have to edit the PHP configuration file. Find the line
error_reporting = E_ALL
and replace it with:
error_reporting = E_ALL ^ E_DEPRECATED
If you don’t have access to the configuration file you can add this line to the PHP WordPress file (maybe headers.php):
error_reporting(E_ALL ^ E_DEPRECATED);
answered May 10, 2010 at 15:15
KrekerKreker
2,4383 gold badges23 silver badges27 bronze badges
1
I just faced a similar problem where a SEO plugin issued a big number of warnings making my blog disk use exceed the plan limit.
I found out that you must include the error_reporting command after the wp-settings.php require in the wp-config.php file:
require_once( ABSPATH .'wp-settings.php' );
error_reporting( E_ALL ^ ( E_NOTICE | E_WARNING | E_DEPRECATED ) );
by doing this no more warnings, notices nor deprecated lines are appended to your error log file!
Tested on WordPress 3.8 but I guess it works for every installation.
answered Mar 28, 2014 at 18:11
CamaleoCamaleo
1,18014 silver badges14 bronze badges
1
All the previous answers are correct. Since no one have hinted out how to turn off all errors in PHP, I would like to mention it here:
error_reporting(0); // Turn off warning, deprecated,
// notice everything except error
Somebody might find it useful…
answered Oct 9, 2011 at 2:44
sudipsudip
2,7811 gold badge30 silver badges41 bronze badges
0
In file wp-config.php you can find constant WP_DEBUG. Make sure it is set to false.
define('WP_DEBUG', false);
This is for WordPress 3.x.
answered Jan 24, 2013 at 13:18
AudriusAudrius
1271 silver badge2 bronze badges
0
I tend to use this method
$errorlevel=error_reporting();
$errorlevel=error_reporting($errorlevel & ~E_DEPRECATED);
In this way I do not turn off accidentally something I need
answered Feb 10, 2017 at 11:04
realteborealtebo
24k38 gold badges112 silver badges191 bronze badges
5
If PHP warnings are breaking things in WordPress, but you still want to know what the warnings are, you can disable displaying PHP errors/warnings and only send them to the log file:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
answered Jan 18 at 8:57
GavinGavin
7,5644 gold badges52 silver badges72 bronze badges
this error occur when you change your php version: it’s very simple to suppress this error message
To suppress the DEPRECATED Error message, just add below code into your index.php file:
init_set(‘display_errors’,False);
answered Dec 16, 2017 at 10:00
1
Home / Prevent E_DEPRECATED error messages in PHP
PHP 5.3 introduced a new error reporting level E_DEPRECATED which is triggered when deprecated functions and methods are used, such as the old style ereg() regular expression functions. This post shows how to suppress E_DEPRECATED error messages.
In PHP.ini
To show all errors other than E_DEPRECATED in the php.ini file, adjust the error_reporting setting as shown below. Note this should only be done for installs of PHP 5.3+.
error_reporting = E_ALL & ~E_DEPRECATED
To suppress notices as well:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED
In code with error_reporting
You can either straight out set the error reporting level like so:
error_reporting(E_ALL &~ E_DEPRECATED); error_reporting(E_ALL &~ E_NOTICE &~ E_DEPRECATED);
or remove E_DEPRECATED from the current error_reporting level:
error_reporting(error_reporting() & ~E_DEPRECATED);
Making it safe for earlier versions of PHP
The only catch with the above error_reporting examples is that if you’re running the same code on e.g. PHP 5.2 as well as PHP 5.3 then you’ll get a notice in PHP 5.2 (and earlier) like «Notice: Use of undefined constant E_DEPRECATED».
To avoid triggering this notice check if E_DEPRECATED is defined:
if(defined('E_DEPRECATED')) {
error_reporting(E_ALL &~ E_DEPRECATED);
}
if(defined('E_DEPRECATED')) {
error_reporting(error_reporting() & ~E_DEPRECATED);
}
Development vs production
While you certainly won’t want to trigger E_DEPRECATED messages in production, you may well want to show them in development to make it easy to locate and update code with deprecated functions. (Note you can suppress the display of error messages regardless of the error_reporting level with display_errors).
In my case, I’ve been using SilverStripe 2.4 which occasionally makes use of the ereg() functions and I prefer not to have the messages displayed even in development. SS 3 will come out later this year and I’m sure they’ll have replaced the ereg functions with preg equivilents. Maybe then I’ll switch back E_DEPRECATED in development.
Данное предупреждение связано с использованием PHP версии 5.3 или выше. В PHP 5.3 некоторые функции, параметры и возможности были отмечены как DEPRECATED (НЕИСПОЛЬЗУЕМЫЕ). В последующих версиях они будут удалены.
В частности, неиспользуемой возможностью стало использование конструкций вида:
$instance = & new SimpleClass();
Можно либо
1) перейти на более старую версию PHP
2) отключить показ DEPRECATE ошибок
Для этого в php.ini установить:
|
error_reporting =E_ALL &~ E_DEPRECATED |
или в PHP файле задать:
|
error_reporting (E_ALL &~ E_DEPRECATED); |
Можно с помощью функции phpinfo() проверить каким на данный момент установлен уровень error_reporting. Он показывается там числовым значением.
Если указанный способ отключить показ DEPRECATED не работает — проверьте наличае других вызовов функции error_reporing.
Но нужно учесть, что с выходом PHP 6.0 данная конструкция будет вообще запрещена к использованию.
3) А лучше всего — немножко поредактировать код.
Например, большинство DEPRECATED в коде Joomla 1.0 и разных модулей было связано именно с использованием & перед new. Например:
|
$module =& new ExtendedMenuModule(); |
Нужно просто удалить &.
Однако таких мест много. Но, если мы используем Eclipse, то просто заменить все вхождения «& new» на «new» во всех файлах. Для этого в меню выбираем Search>Search. Далее выбираем FileSearch, в поле containing text вводим «& new», нажимаем на кнопку Replace.
Будет осуществлён поиск по всем файлам проекта. И через некоторое время появится окошко Replace Text Matches.
C помощью кнопки Preview рассматриваем код, в котором будет произведена замена. И если всё нам нравится — то в нём в поле With вводим » new». И нажимаем OK
Если не сработало (у меня почему-то так произошло) обновляем весь проект (устанавливаем курсор на папку проекта и нажимаем F5) и повторям замену.
Возможны и исключения. Например, \modules\exmenu\loader\menu.menuloader.class.php on line 286. Если там удалить &, то меню работает некорректно.
Подробнее об изменениях в версии 5.3: http://php.su/php/?migration53
Для отключения функционала, помеченного как устаревший (deprecated) в PHP, нужно указать его в параметре error_reporting и не забыть поднять уровень сообщений об ошибках для вывода сообщений о deprecated.
Например, если нужно отключить deprecated для функций, можно использовать следующий код:
error_reporting(E_ALL & ~E_DEPRECATED);
ini_set('display_errors', 'On');
Также можно создать специальный обработчик ошибок, который будет игнорировать устаревшие функции:
function ignoreDeprecated($errno, $errstr, $errfile, $errline) {
if (!(error_reporting() & E_DEPRECATED)) {
return;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler('ignoreDeprecated');
Этот обработчик ошибок пропускает все сообщения, кроме устаревших функций, которые он обрабатывает как исключение. Таким образом, если код содержит вызов устаревшей функции, ошибка будет обработана и не приведет к сбою выполнения всего скрипта.
PHP : Turn off deprecated errors in PHP 5.3
Fix create_function() is deprecated — Critical error WordPress PHP
New in PHP 8.2 — Deprecate Dynamic Property Declaration
7 ошибок при изучении Php
PHP Warning Deprecated: Creation of dynamic property is deprecated
\
Deprecated Dynamic Properties in PHP 8.2
Deprecated Error Required parameter follows optional parameter in WordPress and Php Script-Live Fix
Deprecated Function get magic quotes runtime
How To Fix Elementor \



