Tuesday, December 5, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  0] [ 0]  / answers: 1 / hits: 1011  / 2 Years ago, sun, june 5, 2022, 1:52:55

Since applying some updates to the server this morning, running certain wp cli commands returns a PHP Fatal Error.

An example would be...
wp cache flush

This worked yesterday, but now I get...

PHP Fatal error:  Uncaught Error: Undefined constant "WP_CONTENT_DIR" in /sites/www.mywebsite.com/files/wp-includes/load.php:115
Stack trace:
#0 /sites/www.mywebsite.com/files/wp-settings.php(37): wp_check_php_mysql_versions()
#1 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1237): require('...')
#2 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1158): WP_CLIRunner->load_wordpress()
#3 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLIRunner->start()
#4 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php(74): WP_CLIBootstrapLaunchRunner->process()
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php(27): WP_CLIootstrap()
#6 phar:///usr/local/bin/wp/php/boot-phar.php(11): include('...')
#7 /usr/local/bin/wp(4): include('...')
#8 {main}
thrown in /sites/www.mywebsite.com/files/wp-includes/load.php on line 115

The code it references is the 2nd IF statement, in the following function...

function wp_check_php_mysql_versions() {
global $required_php_version, $wp_version;
$php_version = phpversion();

if ( version_compare( $required_php_version, $php_version, '>' ) ) {
$protocol = wp_get_server_protocol();
header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
header( 'Content-Type: text/html; charset=utf-8' );
printf( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.', $php_version, $wp_version, $required_php_version );
exit( 1 );

if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! extension_loaded( 'mysqlnd' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
require_once ABSPATH . WPINC . '/functions.php';
$args = array(
'exit' => false,
'code' => 'mysql_not_found',
__( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ),
__( 'Requirements Not Met' ),
exit( 1 );

I can see that it's checking php and mysql versions and having ran updates today, these may well have changed, which is why I'm getting the issue.

I've got WordPress set to log errors and it's logging other errors successfully, such as if I break the db connection info temporarily. The error messages in the function above don't appear to be getting displayed anywhere. I'd like to think that if "Your PHP installation appears to be missing the MySQL extension which is required by WordPress." was true, I'd be having much bigger issues than just wp cli commands not running.

It looks to me like the WordPress function isn't finding what it needs on the server, but that's about as far as my knowledge goes.

Would it be wishful thinking to hope more updates will be released tomorrow, which once installed, will make this issue go away?

I'm using mariadb, so for a newbie like me, it's adding extra confusion when the issue appears to be related to php and mysql version.

The issue is occurring on Ubuntu 18.04 and 20.04, with both PHP 7.3 and 7.4.

Any guidance would be greatly appreciated.

More From » php


Check the PHP version on the server, we had the same issue today due to this:


[#2563] Monday, June 6, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 403
Total Questions: 118
Total Answers: 109

Location: Andorra
Member since Mon, Jan 9, 2023
12 Months ago