From 1c574a4d6b7f0d9a234eabb2dd1eb9e1d996229d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 17 May 2019 18:16:54 +0000 Subject: [PATCH] Upgrade/Install: Improve error messages displayed when WordPress update fails due to an incompatible PHP version by linking to the Update PHP support page. Additionally, fix a regression in [44451] where the error message in `wp-admin/upgrade.php` was prepared, but never displayed. Props afragen, netweb, hareesh-pillai, SergeyBiryukov. Merges [45357] to the 5.2 branch. Fixes #46937. Built from https://develop.svn.wordpress.org/branches/5.2@45358 git-svn-id: http://core.svn.wordpress.org/branches/5.2@45169 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/update-core.php | 12 ++++++++++-- wp-admin/install.php | 12 ++++++++++-- wp-admin/update-core.php | 12 ++++++++++-- wp-admin/upgrade.php | 14 ++++++++++++-- wp-includes/version.php | 2 +- 5 files changed, 43 insertions(+), 9 deletions(-) diff --git a/wp-admin/includes/update-core.php b/wp-admin/includes/update-core.php index b0b86166ad..02461acf8c 100644 --- a/wp-admin/includes/update-core.php +++ b/wp-admin/includes/update-core.php @@ -946,10 +946,18 @@ function update_core( $from, $to ) { $wp_filesystem->delete( $from, true ); } + /* translators: %s: Update PHP page URL */ + $php_update_message = '

' . sprintf( __( 'Learn more about updating PHP.' ), esc_url( wp_get_update_php_url() ) ); + + $annotation = wp_get_update_php_annotation(); + if ( $annotation ) { + $php_update_message .= '

' . $annotation . ''; + } + if ( ! $mysql_compat && ! $php_compat ) { - return new WP_Error( 'php_mysql_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.' ), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) ); + return new WP_Error( 'php_mysql_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher and MySQL version %3$s or higher. You are running PHP version %4$s and MySQL version %5$s.' ), $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) . $php_update_message ); } elseif ( ! $php_compat ) { - return new WP_Error( 'php_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version ) ); + return new WP_Error( 'php_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires PHP version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_php_version, $php_version ) . $php_update_message ); } elseif ( ! $mysql_compat ) { return new WP_Error( 'mysql_not_compatible', sprintf( __( 'The update cannot be installed because WordPress %1$s requires MySQL version %2$s or higher. You are running version %3$s.' ), $wp_version, $required_mysql_version, $mysql_version ) ); } diff --git a/wp-admin/install.php b/wp-admin/install.php index 4a38eab1cd..8db4817ceb 100644 --- a/wp-admin/install.php +++ b/wp-admin/install.php @@ -243,12 +243,20 @@ $version_url = sprintf( sanitize_title( $wp_version ) ); +/* translators: %s: Update PHP page URL */ +$php_update_message = '

' . sprintf( __( 'Learn more about updating PHP.' ), esc_url( wp_get_update_php_url() ) ); + +$annotation = wp_get_update_php_annotation(); +if ( $annotation ) { + $php_update_message .= '

' . $annotation . ''; +} + if ( ! $mysql_compat && ! $php_compat ) { /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number */ - $compat = sprintf( __( 'You cannot install because WordPress %2$s requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ); + $compat = sprintf( __( 'You cannot install because WordPress %2$s requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) . $php_update_message; } elseif ( ! $php_compat ) { /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number */ - $compat = sprintf( __( 'You cannot install because WordPress %2$s requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version ); + $compat = sprintf( __( 'You cannot install because WordPress %2$s requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version ) . $php_update_message; } elseif ( ! $mysql_compat ) { /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number */ $compat = sprintf( __( 'You cannot install because WordPress %2$s requires MySQL version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_mysql_version, $mysql_version ); diff --git a/wp-admin/update-core.php b/wp-admin/update-core.php index 570703e5d8..cf20226499 100644 --- a/wp-admin/update-core.php +++ b/wp-admin/update-core.php @@ -76,12 +76,20 @@ function list_core_update( $update ) { sanitize_title( $update->current ) ); + /* translators: %s: Update PHP page URL */ + $php_update_message = '

' . sprintf( __( 'Learn more about updating PHP.' ), esc_url( wp_get_update_php_url() ) ); + + $annotation = wp_get_update_php_annotation(); + if ( $annotation ) { + $php_update_message .= '

' . $annotation . ''; + } + if ( ! $mysql_compat && ! $php_compat ) { /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number */ - $message = sprintf( __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version ); + $message = sprintf( __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $update->current, $update->php_version, $update->mysql_version, $php_version, $mysql_version ) . $php_update_message; } elseif ( ! $php_compat ) { /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number */ - $message = sprintf( __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $update->current, $update->php_version, $php_version ); + $message = sprintf( __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $update->current, $update->php_version, $php_version ) . $php_update_message; } elseif ( ! $mysql_compat ) { /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number */ $message = sprintf( __( 'You cannot update because WordPress %2$s requires MySQL version %3$s or higher. You are running version %4$s.' ), $version_url, $update->current, $update->mysql_version, $mysql_version ); diff --git a/wp-admin/upgrade.php b/wp-admin/upgrade.php index 330ef0fd9d..2047c16881 100644 --- a/wp-admin/upgrade.php +++ b/wp-admin/upgrade.php @@ -85,16 +85,26 @@ elseif ( ! $php_compat || ! $mysql_compat ) : sanitize_title( $wp_version ) ); + /* translators: %s: Update PHP page URL */ + $php_update_message = '

' . sprintf( __( 'Learn more about updating PHP.' ), esc_url( wp_get_update_php_url() ) ); + + $annotation = wp_get_update_php_annotation(); + if ( $annotation ) { + $php_update_message .= '

' . $annotation . ''; + } + if ( ! $mysql_compat && ! $php_compat ) { /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Minimum required MySQL version number, 5: Current PHP version number, 6: Current MySQL version number */ - $message = sprintf( __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ); + $message = sprintf( __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher and MySQL version %4$s or higher. You are running PHP version %5$s and MySQL version %6$s.' ), $version_url, $wp_version, $required_php_version, $required_mysql_version, $php_version, $mysql_version ) . $php_update_message; } elseif ( ! $php_compat ) { /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required PHP version number, 4: Current PHP version number */ - $message = sprintf( __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version ); + $message = sprintf( __( 'You cannot update because WordPress %2$s requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version ) . $php_update_message; } elseif ( ! $mysql_compat ) { /* translators: 1: URL to WordPress release notes, 2: WordPress version number, 3: Minimum required MySQL version number, 4: Current MySQL version number */ $message = sprintf( __( 'You cannot update because WordPress %2$s requires MySQL version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_mysql_version, $mysql_version ); } + + echo '

' . $message . '

'; ?>