admin管理员组文章数量:1130349
With define('WP_DEBUG', true); in wp-config.php, I get the following notice:
Constant EMPTY_TRASH_DAYS already defined in /wp-config.php on line 83
I have checked this file, and this constant is defined just once. I've also searched through all of the php files on the server and don't see that it's defined anywhere else. I've run a thorough search. The only other place it's defined is in default-constants.php:
if ( !defined( 'EMPTY_TRASH_DAYS' ) )
define( 'EMPTY_TRASH_DAYS', 30 );
By commenting out the second line, the notice disappears. But it doesn't make sense to have to edit default-constants.php in order to define the constant in the proper place, which is wp-config.php.
How should I define this constant properly, without editing default-constants.php, which risks being overwritten during an upgrade?
With define('WP_DEBUG', true); in wp-config.php, I get the following notice:
Constant EMPTY_TRASH_DAYS already defined in /wp-config.php on line 83
I have checked this file, and this constant is defined just once. I've also searched through all of the php files on the server and don't see that it's defined anywhere else. I've run a thorough search. The only other place it's defined is in default-constants.php:
if ( !defined( 'EMPTY_TRASH_DAYS' ) )
define( 'EMPTY_TRASH_DAYS', 30 );
By commenting out the second line, the notice disappears. But it doesn't make sense to have to edit default-constants.php in order to define the constant in the proper place, which is wp-config.php.
How should I define this constant properly, without editing default-constants.php, which risks being overwritten during an upgrade?
2 Answers
Reset to default 4When defining any WordPress constants in wp-config.php you need to do it before this line:
require_once( ABSPATH . 'wp-settings.php' );
That line loads many of WordPress’s default constants, and if you haven’t already defined them yourself then they’ll be defined in that line, meaning that any of them that you try to define after this line will have already been defined.
It means that the constant EMPTY_TRASH_DAYS has been defined twice. You need to check and remove the second definition of the same constant.
It may be that it's been defined somewhere else. So search all the files of WordPress using grep, find or some advanced text editor like Sublime Text
With define('WP_DEBUG', true); in wp-config.php, I get the following notice:
Constant EMPTY_TRASH_DAYS already defined in /wp-config.php on line 83
I have checked this file, and this constant is defined just once. I've also searched through all of the php files on the server and don't see that it's defined anywhere else. I've run a thorough search. The only other place it's defined is in default-constants.php:
if ( !defined( 'EMPTY_TRASH_DAYS' ) )
define( 'EMPTY_TRASH_DAYS', 30 );
By commenting out the second line, the notice disappears. But it doesn't make sense to have to edit default-constants.php in order to define the constant in the proper place, which is wp-config.php.
How should I define this constant properly, without editing default-constants.php, which risks being overwritten during an upgrade?
With define('WP_DEBUG', true); in wp-config.php, I get the following notice:
Constant EMPTY_TRASH_DAYS already defined in /wp-config.php on line 83
I have checked this file, and this constant is defined just once. I've also searched through all of the php files on the server and don't see that it's defined anywhere else. I've run a thorough search. The only other place it's defined is in default-constants.php:
if ( !defined( 'EMPTY_TRASH_DAYS' ) )
define( 'EMPTY_TRASH_DAYS', 30 );
By commenting out the second line, the notice disappears. But it doesn't make sense to have to edit default-constants.php in order to define the constant in the proper place, which is wp-config.php.
How should I define this constant properly, without editing default-constants.php, which risks being overwritten during an upgrade?
-
1
The load process is
index.php(in install root, not your theme) ->wp-blog-header.php->wp-load.php->wp-config.php. That notice is telling you where it's attempting to set the constant a 2nd time. It seems very strange to see that error that early in the process where only core files have been loaded. I would start by switching to a default theme and disabling all plugins, check if error is still present, then re-enable one-by-one. – Milo Commented Oct 25, 2018 at 3:45 -
Thank you @Milo! Disabling all plugins and reverting to 2017 theme didn't seem to help. However I found that by commenting out a line in
default-constants.phpthe notice disappears. I've edited the question to include this updated information. However, the problem still isn't fully resolved, in that I shouldn't have to editdefault-constants.php.– Kit Johnson Commented Oct 25, 2018 at 11:26 -
1
In wp-config.php there's this line:
require_once( ABSPATH . 'wp-settings.php' );. Is yourdefine( 'EMPTY_TRASH_DAYS', 30 );before this line? – Jacob Peattie Commented Oct 25, 2018 at 11:33 - Yay @JacobPeattie you solved it! Shall I write up your comment as an answer or would you prefer to do that yourself? – Kit Johnson Commented Oct 27, 2018 at 4:27
2 Answers
Reset to default 4When defining any WordPress constants in wp-config.php you need to do it before this line:
require_once( ABSPATH . 'wp-settings.php' );
That line loads many of WordPress’s default constants, and if you haven’t already defined them yourself then they’ll be defined in that line, meaning that any of them that you try to define after this line will have already been defined.
It means that the constant EMPTY_TRASH_DAYS has been defined twice. You need to check and remove the second definition of the same constant.
It may be that it's been defined somewhere else. So search all the files of WordPress using grep, find or some advanced text editor like Sublime Text
本文标签: wp configHow can I resolve the php notice quotConstant EMPTYTRASHDAYS already definedquot
版权声明:本文标题:wp config - How can I resolve the php notice "Constant EMPTY_TRASH_DAYS already defined" 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749228930a2336154.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


index.php(in install root, not your theme) ->wp-blog-header.php->wp-load.php->wp-config.php. That notice is telling you where it's attempting to set the constant a 2nd time. It seems very strange to see that error that early in the process where only core files have been loaded. I would start by switching to a default theme and disabling all plugins, check if error is still present, then re-enable one-by-one. – Milo Commented Oct 25, 2018 at 3:45default-constants.phpthe notice disappears. I've edited the question to include this updated information. However, the problem still isn't fully resolved, in that I shouldn't have to editdefault-constants.php.– Kit Johnson Commented Oct 25, 2018 at 11:26require_once( ABSPATH . 'wp-settings.php' );. Is yourdefine( 'EMPTY_TRASH_DAYS', 30 );before this line? – Jacob Peattie Commented Oct 25, 2018 at 11:33