From c4f20a64d7e4470d34c0233fde165ba68596fff6 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 5 Oct 2026 21:05:31 +0000 Subject: [PATCH 1/3] Use update check data to validate installed theme versions `wp theme list`, `wp theme status` and `wp theme update` made a themes_api() request for every installed theme to find out whether the installed version is higher than the one on WordPress.org. The update check already returns the latest version of every WordPress.org theme (in `response` or `no_update`), so use that and only fall back to themes_api() when that information is missing. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS --- features/theme.feature | 36 ++++++++++++++++++++++++++++++ src/WP_CLI/ParseThemeNameInput.php | 31 ++++++++++++++++++++----- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/features/theme.feature b/features/theme.feature index ee136710..e56ef7c7 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -909,3 +909,39 @@ Feature: Manage WordPress themes | name | status | | twentyeleven | active | | twentytwelve | inactive | + + Scenario: Flag themes whose version is higher than the one on WordPress.org without a request per theme + Given a WP install + And I run `wp theme install twentytwelve --force` + And I run `sed -i.bak 's/^Version: .*/Version: 99.0/' wp-content/themes/twentytwelve/style.css` + And a wp-content/themes/my-local-theme/style.css file: + """ + /* + Theme Name: My Local Theme + Version: 1.0 + */ + """ + And a wp-content/themes/my-local-theme/index.php file: + """ + $version ) { - $theme_version_info[ $slug ] = $this->is_theme_version_valid( $slug, $version ); + $theme_version_info[ $slug ] = $this->is_theme_version_valid( $slug, $version, $all_update_info ); } } @@ -184,14 +184,33 @@ private function get_all_themes() { } /** - * Check if current version of the theme is higher than the one available at WP.org. + * Check whether the installed version of a theme is not higher than the latest version on WordPress.org. * - * @param string $slug Theme slug. - * @param string $version Theme current version. + * The update check already returns the latest version of every theme hosted on WordPress.org, + * in `response` for themes with an update and in `no_update` for the others, so this does not + * need a request per theme unless that information is missing. * - * @return bool|string + * @param string $slug Theme slug. + * @param string $version Installed theme version. + * @param object|null $update_info Optional. Value of the `update_themes` site transient. + * + * @return bool|string Whether the version is valid, or an empty string for themes not on WordPress.org. */ - protected function is_theme_version_valid( $slug, $version ) { + protected function is_theme_version_valid( $slug, $version, $update_info = null ) { + if ( is_object( $update_info ) && isset( $update_info->no_update ) ) { + $latest = null; + foreach ( [ 'response', 'no_update' ] as $key ) { + $themes = isset( $update_info->$key ) ? (array) $update_info->$key : []; + if ( isset( $themes[ $slug ]['new_version'] ) ) { + $latest = (string) $themes[ $slug ]['new_version']; + break; + } + } + + // Themes that are not on WordPress.org are not part of the update check response. + return null === $latest ? '' : ! version_compare( $version, $latest, '>' ); + } + /** * @var \WP_Error|object{name: string, slug: string, version: string, download_link: string} $theme_info */ From 3458f13cdd7d7b14a320912befc9ea61df0f9630 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 06:26:15 +0000 Subject: [PATCH 2/3] Handle object update entries and skip the new test before WP 5.5 Update check entries are arrays in core, but filters can turn them into objects, so cast an entry before reading `new_version`. The update check only lists themes without an update in `no_update` since WordPress 5.5. Before that, the per-theme request is still needed, so the new scenario does not apply there. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS --- features/theme.feature | 2 ++ src/WP_CLI/ParseThemeNameInput.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/features/theme.feature b/features/theme.feature index e56ef7c7..a01e2135 100644 --- a/features/theme.feature +++ b/features/theme.feature @@ -910,6 +910,8 @@ Feature: Manage WordPress themes | twentyeleven | active | | twentytwelve | inactive | + # The update check only lists themes without an update in `no_update` since WordPress 5.5. + @require-wp-5.5 Scenario: Flag themes whose version is higher than the one on WordPress.org without a request per theme Given a WP install And I run `wp theme install twentytwelve --force` diff --git a/src/WP_CLI/ParseThemeNameInput.php b/src/WP_CLI/ParseThemeNameInput.php index 78772c76..728b3ee4 100644 --- a/src/WP_CLI/ParseThemeNameInput.php +++ b/src/WP_CLI/ParseThemeNameInput.php @@ -201,8 +201,10 @@ protected function is_theme_version_valid( $slug, $version, $update_info = null $latest = null; foreach ( [ 'response', 'no_update' ] as $key ) { $themes = isset( $update_info->$key ) ? (array) $update_info->$key : []; - if ( isset( $themes[ $slug ]['new_version'] ) ) { - $latest = (string) $themes[ $slug ]['new_version']; + // Entries are arrays in core, but filters can turn them into objects. + $theme = isset( $themes[ $slug ] ) ? (array) $themes[ $slug ] : []; + if ( isset( $theme['new_version'] ) ) { + $latest = (string) $theme['new_version']; break; } } From e2582aef2908323284a046966075755360348dc5 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 06:40:45 +0000 Subject: [PATCH 3/3] Use a plugin that still supports WordPress 6.9 in the PHP requirement test contact-form-7 6.2 requires WordPress 7.1, so on the PHP 7.2/7.3 jobs with WordPress 6.9 the WordPress requirement check fails first and the expected PHP warning never shows. wp-mail-smtp requires PHP 7.4 and WordPress 5.5. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01D26yjkN2BiqCXT6p6o1WqS (cherry picked from commit d5b97c009d0cfe2f32607b57cfed79a6c13277bd) --- features/plugin-install.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/plugin-install.feature b/features/plugin-install.feature index 2e10f027..36dfa55d 100644 --- a/features/plugin-install.feature +++ b/features/plugin-install.feature @@ -310,10 +310,10 @@ Feature: Install WordPress plugins Scenario: Can't install plugin that requires a newer version of PHP Given a WP install - And I try `wp plugin install contact-form-7` + And I try `wp plugin install wp-mail-smtp` Then STDERR should contain: """ - Warning: contact-form-7: This plugin does not work with your version of PHP + Warning: wp-mail-smtp: This plugin does not work with your version of PHP """ And STDERR should contain: