From 3f641505fea044df3d80006e209e5fc66a9477fe Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 17 May 2019 12:33:50 +0000 Subject: [PATCH] Build/Test Tools: Use a non-zero exit code in `wp_check_php_mysql_versions()` when minimum PHP or MySQL requirements are not met. This allows automated scripts and test suites to interpret the result correctly. Props jrf, spacedmonkey. Fixes #47169. git-svn-id: https://develop.svn.wordpress.org/trunk@45350 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/load.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/wp-includes/load.php b/src/wp-includes/load.php index 05d37f5a79..7c9c2e7757 100644 --- a/src/wp-includes/load.php +++ b/src/wp-includes/load.php @@ -136,16 +136,23 @@ function wp_check_php_mysql_versions() { header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); header( 'Content-Type: text/html; charset=utf-8' ); /* translators: 1: Current PHP version number, 2: WordPress version number, 3: Minimum required PHP version number */ - die( sprintf( __( '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' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) { + require_once( ABSPATH . WPINC . '/functions.php' ); wp_load_translations_early(); - - $protocol = wp_get_server_protocol(); - header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 ); - header( 'Content-Type: text/html; charset=utf-8' ); - die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) ); + $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.' ), + __( 'Insufficient Requirements' ), + $args + ); + exit( 1 ); } }