From 0205cf09f07664c16aef4efbb35fd47ffd9c6d37 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 17 May 2019 18:10:55 +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. Fixes #46937. git-svn-id: https://develop.svn.wordpress.org/trunk@45357 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/update-core.php | 12 ++++++++++-- src/wp-admin/install.php | 12 ++++++++++-- src/wp-admin/update-core.php | 12 ++++++++++-- src/wp-admin/upgrade.php | 14 ++++++++++++-- 4 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php index b0b86166ad..02461acf8c 100644 --- a/src/wp-admin/includes/update-core.php +++ b/src/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/src/wp-admin/install.php b/src/wp-admin/install.php index 4a38eab1cd..8db4817ceb 100644 --- a/src/wp-admin/install.php +++ b/src/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/src/wp-admin/update-core.php b/src/wp-admin/update-core.php index 570703e5d8..cf20226499 100644 --- a/src/wp-admin/update-core.php +++ b/src/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/src/wp-admin/upgrade.php b/src/wp-admin/upgrade.php index 330ef0fd9d..2047c16881 100644 --- a/src/wp-admin/upgrade.php +++ b/src/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 . '

'; ?>