From 87d5bcd6c9521b7a69b4146edf8ab37ea7afc14a Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 29 Sep 2023 07:23:54 -0700 Subject: [PATCH 1/3] Fix `--skip-themes` for WordPress 6.4 WordPress 6.4 added some memoization that impacts `get_template_directory()` and `get_stylesheet_directory()`. Fortunately, we only need to noop the global to fix `--skip-themes`. --- php/WP_CLI/Runner.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index 97904eb500..61801ca0eb 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -1793,6 +1793,10 @@ public function action_setup_theme_wp_cli_skip_themes() { add_filter( $hook, $wp_cli_filter_active_theme, 999 ); } + // Noop memoization added in WP 6.4. + $GLOBALS['wp_stylesheet_path'] = null; + $GLOBALS['wp_template_path'] = null; + // Remove theme-related actions not directly tied into the theme lifecycle. if ( WP_CLI::get_runner()->config['skip-themes'] ) { $theme_related_actions = [ @@ -1812,6 +1816,9 @@ static function () use ( $hooks, $wp_cli_filter_active_theme ) { foreach ( $hooks as $hook ) { remove_filter( $hook, $wp_cli_filter_active_theme, 999 ); } + // Noop memoization added in WP 6.4 again. + $GLOBALS['wp_stylesheet_path'] = null; + $GLOBALS['wp_template_path'] = null; }, 0 ); From b32e50dcd2e294c50858ecebaa5b6529bef1c5d2 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 29 Sep 2023 07:33:57 -0700 Subject: [PATCH 2/3] Fix PHPCS issues --- php/WP_CLI/Runner.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/php/WP_CLI/Runner.php b/php/WP_CLI/Runner.php index 61801ca0eb..b98fc61b64 100644 --- a/php/WP_CLI/Runner.php +++ b/php/WP_CLI/Runner.php @@ -1794,8 +1794,10 @@ public function action_setup_theme_wp_cli_skip_themes() { } // Noop memoization added in WP 6.4. + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WordPress core global. $GLOBALS['wp_stylesheet_path'] = null; - $GLOBALS['wp_template_path'] = null; + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WordPress core global. + $GLOBALS['wp_template_path'] = null; // Remove theme-related actions not directly tied into the theme lifecycle. if ( WP_CLI::get_runner()->config['skip-themes'] ) { @@ -1817,8 +1819,10 @@ static function () use ( $hooks, $wp_cli_filter_active_theme ) { remove_filter( $hook, $wp_cli_filter_active_theme, 999 ); } // Noop memoization added in WP 6.4 again. + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WordPress core global. $GLOBALS['wp_stylesheet_path'] = null; - $GLOBALS['wp_template_path'] = null; + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- WordPress core global. + $GLOBALS['wp_template_path'] = null; }, 0 ); From 1b74ae34740c774245e388dbc974d86aaf062d74 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Fri, 29 Sep 2023 07:56:04 -0700 Subject: [PATCH 3/3] Remove themes directory to prevent missing function fatals --- features/requests.feature | 2 ++ 1 file changed, 2 insertions(+) diff --git a/features/requests.feature b/features/requests.feature index 5cf1490937..e1df780c2d 100644 --- a/features/requests.feature +++ b/features/requests.feature @@ -25,6 +25,7 @@ Feature: Requests integration with both v1 and v2 Given a WP installation And I run `vendor/bin/wp core update --version=5.8 --force` + And I run `rm -r wp-content/themes/*` When I run `vendor/bin/wp core version` Then STDOUT should contain: @@ -46,6 +47,7 @@ Feature: Requests integration with both v1 and v2 Scenario: Current version with WordPress-bundled Requests v1 Given a WP installation And I run `wp core update --version=5.8 --force` + And I run `rm -r wp-content/themes/*` When I run `wp core version` Then STDOUT should contain: