Bootstrap/Load: Check that either `mysqli_connect()` or `mysql_connect()` is available.
This resolves a fatal error and displays an actionable message if the `mysqli` PHP extension is missing. Previously, `wp_check_php_mysql_versions()` performed an early check whether `mysql`, `mysqli`, or `mysqlnd` extensions are loaded, but that did not work if the `mysqlnd` extension is the only one present. Checking specifically for `mysqli_connect()` or `mysql_connect()` functions should be a more reliable approach and more closely mirrors the existing checks in the `wpdb` class. Follow-up to [1955], [4489], [7234], [12732], [19760], [27257], [36434]. Props bgin, desrosj, dimadin, ipajen, hellofromTonya, sc0ttkclark, azaozz, SergeyBiryukov. Fixes #51988. Built from https://develop.svn.wordpress.org/trunk@55367 git-svn-id: http://core.svn.wordpress.org/trunk@54900 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4046f55c78
commit
89a3b0e9f2
|
@ -149,23 +149,43 @@ function wp_check_php_mysql_versions() {
|
|||
$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 );
|
||||
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' )
|
||||
if ( ! function_exists( 'mysqli_connect' ) && ! function_exists( 'mysql_connect' )
|
||||
// This runs before default constants are defined, so we can't assume WP_CONTENT_DIR is set yet.
|
||||
&& ( defined( 'WP_CONTENT_DIR' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' )
|
||||
|| ! file_exists( ABSPATH . 'wp-content/db.php' ) )
|
||||
) {
|
||||
require_once ABSPATH . WPINC . '/functions.php';
|
||||
wp_load_translations_early();
|
||||
|
||||
$message = '<p>' . __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) . "</p>\n";
|
||||
|
||||
$message .= '<p>' . sprintf(
|
||||
/* translators: %s: mysqli. */
|
||||
__( 'Please check that the %s PHP extension is installed and enabled.' ),
|
||||
'<code>mysqli</code>'
|
||||
) . "</p>\n";
|
||||
|
||||
$message .= '<p>' . sprintf(
|
||||
/* translators: %s: Support forums URL. */
|
||||
__( 'If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href="%s">WordPress Support Forums</a>.' ),
|
||||
__( 'https://wordpress.org/support/forums/' )
|
||||
) . "</p>\n";
|
||||
|
||||
$args = array(
|
||||
'exit' => false,
|
||||
'code' => 'mysql_not_found',
|
||||
);
|
||||
wp_die(
|
||||
__( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ),
|
||||
$message,
|
||||
__( 'Requirements Not Met' ),
|
||||
$args
|
||||
);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.2-beta2-55366';
|
||||
$wp_version = '6.2-beta2-55367';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue