WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 2 months ago

Last modified 4 weeks ago

#46937 closed enhancement (fixed)

Provide update-php link on WordPress update failure screen

Reported by: Hareesh Pillai Owned by: SergeyBiryukov
Milestone: 5.2.1 Priority: normal
Severity: normal Version: 5.2
Component: Site Health Keywords: servehappy has-patch has-screenshots dev-feedback needs-testing i18n-change
Focuses: Cc:

Description

When WordPress update fails due to an incompatible PHP version, the error message can be improved by displaying a link to the Update PHP page.

Attachments (7)

WordPress update fail.png (95.6 KB) - added by Hareesh Pillai 3 months ago.
WordPress update fail - PHP Notice.png (113.4 KB) - added by Hareesh Pillai 3 months ago.
WP52-Update-Screen.png (44.5 KB) - added by netweb 3 months ago.
46937.diff (10.1 KB) - added by afragen 2 months ago.
46937-wpcs.diff (17.8 KB) - added by afragen 2 months ago.
includes other WPCS fixes
php_annotation.png (45.2 KB) - added by afragen 2 months ago.
php_annotation_plus.png (59.5 KB) - added by afragen 2 months ago.

Download all attachments as: .zip

Change History (19)

#1 @SergeyBiryukov
3 months ago

  • Component changed from General to Upgrade/Install

This ticket was mentioned in Slack in #core by afragen. View the logs.


3 months ago

#3 @netweb
3 months ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 5.2.1

The screenshot above is from one of my sites not yet running PHP > 5.6

Here's the text for copy/paste purposes:

You cannot update because WordPress 5.2 requires PHP version 5.6.20 or higher. You are running version 5.5.9-1ubuntu4.27.

This localised version contains both the translation and various other localisation fixes. You can skip upgrading if you want to keep your current translation.

You cannot update because WordPress 5.2 requires PHP version 5.6.20 or higher. You are running version 5.5.9-1ubuntu4.27.

While your site is being updated, it will be in maintenance mode. As soon as your updates are complete, your site will return to normal.

The notice is displayed twice I believe because I'm running an #en-au localized install.

Lets include a link to https://wordpress.org/support/update-php/ in that notice so that users can access a resource to help guide them to upgrading PHP so that they can upgrade WP


For a start a quick look reveals the helper wp_get_update_php_url() function, using that to create a patch to include the localised URL for each of the PHP upgrade messages in:

src/wp-admin/install.php
248:    $compat = sprintf( __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> 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 );
251:    $compat = sprintf( __( 'You cannot install because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version );

src/wp-admin/update-core.php
81:                             $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> 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 );
84:                             $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $update->current, $update->php_version, $php_version );

src/wp-admin/upgrade.php
90:             $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> 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 );
93:             $message = sprintf( __( 'You cannot update because <a href="%1$s">WordPress %2$s</a> requires PHP version %3$s or higher. You are running version %4$s.' ), $version_url, $wp_version, $required_php_version, $php_version );

src/wp-admin/includes/update-core.php
950:            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 ) );
952:            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 ) );

@afragen
2 months ago

@afragen
2 months ago

includes other WPCS fixes

#4 @afragen
2 months ago

  • Keywords has-patch has-screenshots dev-feedback needs-testing added; needs-patch removed

Both of the patches 46937.diff and 46937-wpcs.diff should fix this issue. The second patch 46937-wpcs.diff also updates the modified files for WPCS.

https://core.trac.wordpress.org/raw-attachment/ticket/46937/php_annotation.png

If the host provides their own update URL the following is displayed.

https://core.trac.wordpress.org/raw-attachment/ticket/46937/php_annotation_plus.png

Last edited 2 months ago by afragen (previous) (diff)

#5 @SergeyBiryukov
2 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#6 @SergeyBiryukov
2 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 45357:

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.

#7 @SergeyBiryukov
2 months ago

In 45358:

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.

#8 @Hareesh Pillai
2 months ago

  • Keywords i18n-change added

This ticket was mentioned in Slack in #core-php by spacedmonkey. View the logs.


2 months ago

#10 @TimothyBlynJacobs
2 months ago

Is there a plan for this to be backported to 5.1 installs? It seems like it'd be helpful to include for those users.

#11 @desrosj
2 months ago

@TimothyBlynJacobs historically only security changes have been backported past the current working branch. If #47160 is tackled and backported, though, I agree that this should accompany it.

Last edited 2 months ago by desrosj (previous) (diff)

#12 @spacedmonkey
4 weeks ago

  • Component changed from Upgrade/Install to Site Health
Note: See TracTickets for help on using tickets.