[wp-trac] [WordPress Trac] #59758: Update Theme via CLI ignores Requires PHP Constraint

WordPress Trac noreply at wordpress.org
Fri Oct 27 15:03:29 UTC 2023


#59758: Update Theme via CLI ignores Requires PHP Constraint
-----------------------------+-----------------------------
 Reporter:  salcode          |      Owner:  (none)
     Type:  defect (bug)     |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Upgrade/Install  |    Version:  trunk
 Severity:  normal           |   Keywords:  needs-patch
  Focuses:                   |
-----------------------------+-----------------------------
 As described in the [https://developer.wordpress.org/themes/basics/main-
 stylesheet-style-css/#explanations Theme Handbook Main Stylesheet
 (style.css) Explanations] the `Requires PHP` line defines

 > The oldest PHP version supported, in X.X format, only the number

 In the WordPress Web UI (`/wp-admin`), you are prevented from updating to
 a newer version of the theme if your server does not meet this requirement
 (in the Themes page, Update is unavailable and in the general Updates
 page, the update fails).

 However, updating the theme via WP CLI ''does'' allow updating a theme to
 a version even if the theme requires a version of PHP that exceeds the
 requirement.

 == Reproduction Steps

 To test this we will use the [https://wordpress.org/themes/rider/ Rider
 Theme] from the  wordpress.org Themes Repository.

 ||= Rider Version =||= Requires PHP =||
 || 2.1.0 ||  5.6  ||
 || 3.0.0 ||  8.1  ||



 1. Run WordPress on a server with PHP version `8.0`
   - e.g. if you are using the [https://github.com/wordpress/wordpress-
 develop/ WordPress development repo], change the `LOCAL_PHP` value in
 `.env` from `latest` to `8.0-fpm` and restart
   - you can confirm your PHP version with the WP CLI task `wp --info` and
 checking the `PHP version` in the output, this task can be run on the
 [https://github.com/wordpress/wordpress-develop/ WordPress development
 repository] with
 {{{
 npm run env:cli -- wp --info
 }}}
 2. Install and activate version `2.1.0` of the Rider theme (which Requires
 PHP `5.6`) `wp theme install rider --version=2.1.0 --activate`
   - this task can be run on the WordPress development repo with
 {{{
 npm run env:cli -- wp theme install rider --version=2.1.0 --activate
 }}}
 3. Update the Rider theme to the latest version (`3.0.0`), which Requires
 PHP `8.1` `wp theme update rider`
   - this task can be run on the WordPress development repo with
 {{{
 npm run env:cli -- wp theme update rider
 }}}

 === Expected Behavior

 The Rider theme is NOT updated because the "Requires PHP" version exceeds
 the version on the server.

 === Actual Behavior
 The Rider theme ''is'' updated to the latest version (`3.0.0`), which has
 a Requires PHP value that exceeds our server.

 == Related Trac Ticket for Plugins

 In #59198 a similar problem with Plugins was addressed.

 == Does this Fix Belong in WordPress Core?

 Since I've only been able to recreate this issue via WP CLI, one might
 argue the fix for this belongs in WP CLI however since we are checking the
 "Requires PHP" value in Plugins here in WordPress core (see #59198), I'd
 argue we should be doing the same for Themes.

 ------


 Props @afragen for calling out this need in
 [https://core.trac.wordpress.org/ticket/59198#comment:4 this comment on
 59198]
 Props @h4l9k for helping write up this issue

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59758>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list