admin管理员组文章数量:1122846
When I reinstalled my Wordpress site on a new server, I was stuck with a HTTP ERROR 500 page, and this showed in the logs :
[proxy_fcgi:error] [pid 87631:tid 140347891410624] [client xxxx:9316] AH01071: Got error
PHP message: PHP Fatal error:
Uncaught Error: Undefined constant "WP_CONTENT_DIR" in /var/www/site/wp-includes/load.php:141
Stack trace:
#0 /var/www/site/wp-settings.php(29): wp_check_php_mysql_versions()
#1 /var/www/site/wp-config.php(92): require_once('/var/www/site...')
#2 /var/www/site/wp-load.php(37): require_once('/var/www/site...')
#3 /var/www/site/wp-blog-header.php(13): require_once('/var/www/site...')
#4 /var/www/site/index.php(17): require('/var/www/site...')
#5 {main}
thrown in /var/www/site/wp-includes/load.php on line 141'
The error occurs inside the call of wp_check_php_mysql_versions() function.
I've seen that this WP_CONTENT_DIR should be loaded in wp-includes/default-constants.php
which is loaded AFTER this call.
Is this a bug in Wordpress ?
When I reinstalled my Wordpress site on a new server, I was stuck with a HTTP ERROR 500 page, and this showed in the logs :
[proxy_fcgi:error] [pid 87631:tid 140347891410624] [client xxxx:9316] AH01071: Got error
PHP message: PHP Fatal error:
Uncaught Error: Undefined constant "WP_CONTENT_DIR" in /var/www/site/wp-includes/load.php:141
Stack trace:
#0 /var/www/site/wp-settings.php(29): wp_check_php_mysql_versions()
#1 /var/www/site/wp-config.php(92): require_once('/var/www/site...')
#2 /var/www/site/wp-load.php(37): require_once('/var/www/site...')
#3 /var/www/site/wp-blog-header.php(13): require_once('/var/www/site...')
#4 /var/www/site/index.php(17): require('/var/www/site...')
#5 {main}
thrown in /var/www/site/wp-includes/load.php on line 141'
The error occurs inside the call of wp_check_php_mysql_versions() function.
I've seen that this WP_CONTENT_DIR should be loaded in wp-includes/default-constants.php
which is loaded AFTER this call.
Is this a bug in Wordpress ?
Share Improve this question asked Apr 21, 2024 at 9:21 OrabîgOrabîg 1113 bronze badges1 Answer
Reset to default 1Yes, this is a bug, but it appear only when the WP configuration is not finished.
The error occurs on this line (in wp-includes/load.php) :
if ( ! extension_loaded( 'mysql' )
&& ! extension_loaded( 'mysqli' )
&& ! extension_loaded( 'mysqlnd' )
&& ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
(...)
This checks that mysql extension is installed, and tries several things for this.
The last check will not work because WP_CONTENT_DIR
is not defined yet at this stage.
The logical way to fix this is to ignore this error, and install PHP mysql extension, like so (in Debian) :
sudo apt install php-mysql
本文标签: phpUncaught Error Undefined constant quotWPCONTENTDIRquot
版权声明:本文标题:php - Uncaught Error: Undefined constant "WP_CONTENT_DIR" 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736309785a1934142.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论