Commit a0dcec74297 for woocommerce
commit a0dcec7429721015b683df3b6592bdc6d3ae79b4
Author: Greg <71906536+zhongruige@users.noreply.github.com>
Date: Wed Dec 2 04:25:57 2026 -0700
Keep WP-CLI 3 from breaking the E2E environment setup (#71673)
* Stop the setup wizard redirect from skipping WP-CLI commands in the E2E environment
Since WP-CLI 3.0, `wp plugin` and `wp theme` commands run as a wp-admin
request, so admin_init fires. Right after WooCommerce is activated on a
fresh install, the setup wizard redirect runs on admin_init and exits,
and the command ends with exit code 0 without doing anything. wp-env
activates each plugin in its own command, WooCommerce first, so the
next plugin in .wp-env.e2e.json would never be activated; in nightly
runs the theme activation in test-env-setup.sh would be skipped.
Add a must-use plugin, mounted by .wp-env.e2e.json, that turns the
redirect off for WP-CLI requests only. The redirect transient is left
in place, so browser requests behave as before. On WP-CLI 2.x, commands
never fire admin_init, so nothing changes there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Also restore WP-CLI 2.x's unlimited memory limit in the E2E environment
A real wp-env run of .wp-env.e2e.json on WP-CLI 3.0.0 showed a second
break. WP-CLI 2.x set memory_limit to -1 for every command; 3.0 doesn't,
and the wordpress:cli image has no php.ini, so commands get PHP's
default 128M. With WooCommerce and the E2E plugins loaded, every
command in test-env-setup.sh other than `wp plugin` and `wp theme`
(which run in the admin context, where WordPress raises the limit) ran
out of memory: rewrite structure, user create, option update, media
import.
The must-use plugin now sets memory_limit back to -1 for WP-CLI
requests, as 2.x did, and is renamed to match what it does. On WP-CLI
2.x the limit is already -1, so nothing changes there.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Run Core API, Blocks E2E and Metrics jobs on E2E mu-plugin changes
These jobs load the must-use plugins in tests/e2e/mu-plugins through
.wp-env.e2e.json, but their changed-file filters didn't include that
directory, so a change to only the shim would skip them. The Core E2E
jobs already match it through their tests/e2e glob.
* Correct the WP-CLI 2.x memory limit note in the E2E mu-plugin
The docblock said the shim has no effect on WP-CLI 2.x. 2.x does reach
an unlimited memory limit before the command runs, but later in
bootstrap: plugins_loaded still sees 128M without the shim. Say that the
shim raises the limit earlier there instead.
* Trim the E2E mu-plugin docblock to what the shim does and why
The details of which commands fail and which activations get skipped
are in the PR description; the file only needs what each part undoes,
why browser requests are unaffected, and why it's a must-use plugin.
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
diff --git a/plugins/woocommerce/.wp-env.e2e.json b/plugins/woocommerce/.wp-env.e2e.json
index 7865d4ec7b2..0028b10ba99 100644
--- a/plugins/woocommerce/.wp-env.e2e.json
+++ b/plugins/woocommerce/.wp-env.e2e.json
@@ -33,6 +33,7 @@
},
"mappings": {
"wp-content/plugins/e2e-test-bin": "./tests/e2e/bin",
+ "wp-content/mu-plugins": "./tests/e2e/mu-plugins",
"wp-content/plugins/llms-txt-provider": "./tests/e2e/test-plugins/llms-txt-provider",
"wp-content/plugins/settings-ui-component-registration": "./tests/e2e/test-plugins/settings-ui-component-registration",
"test-data/images/": "./tests/e2e/test-data/images/",
diff --git a/plugins/woocommerce/changelog/dev-e2e-wp-cli-3-setup-redirect b/plugins/woocommerce/changelog/dev-e2e-wp-cli-3-setup-redirect
new file mode 100644
index 00000000000..b02c1e3c777
--- /dev/null
+++ b/plugins/woocommerce/changelog/dev-e2e-wp-cli-3-setup-redirect
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: E2E environment: keep WP-CLI commands working on WP-CLI 3 (memory limit and setup wizard redirect).
diff --git a/plugins/woocommerce/package.json b/plugins/woocommerce/package.json
index 8ab7ec9b3cb..e2fc75f5a8a 100644
--- a/plugins/woocommerce/package.json
+++ b/plugins/woocommerce/package.json
@@ -737,6 +737,7 @@
"includes/**/*.php",
"src/**/*.php",
"tests/e2e/bin/**",
+ "tests/e2e/mu-plugins/**",
"tests/e2e/tests/api-tests/**",
"tests/e2e/*.js",
"tests/e2e/*.sh",
@@ -772,6 +773,7 @@
"includes/**/*.php",
"src/**/*.php",
"tests/e2e/bin/**",
+ "tests/e2e/mu-plugins/**",
"tests/e2e/tests/api-tests/**",
"tests/e2e/*.js",
"tests/e2e/*.sh",
@@ -808,6 +810,7 @@
"includes/**/*.php",
"src/**/*.php",
"tests/e2e/bin/**",
+ "tests/e2e/mu-plugins/**",
"tests/e2e/tests/api-tests/**",
"tests/e2e/*.js",
"tests/e2e/*.sh",
@@ -875,6 +878,7 @@
"includes/**/*.php",
"src/**/*.php",
"tests/e2e/bin/**",
+ "tests/e2e/mu-plugins/**",
"tests/e2e/tests/api-tests/**",
"tests/e2e/*.js",
"tests/e2e/*.sh",
@@ -929,6 +933,7 @@
"templates/**/*.php",
"templates/**/*.html",
"tests/metrics/**",
+ "tests/e2e/mu-plugins/**",
".wp-env.e2e.json"
],
"onlyForDependencies": [
@@ -963,6 +968,7 @@
"templates/**/*.php",
"templates/**/*.html",
"tests/metrics/**",
+ "tests/e2e/mu-plugins/**",
".wp-env.e2e.json"
],
"onlyForDependencies": [
@@ -1003,6 +1009,7 @@
"templates/**/*.html",
"sample-data/sample_products.xml",
"tests/e2e/bin/**",
+ "tests/e2e/mu-plugins/**",
"tests/e2e/fixtures/blocks-setup.ts",
"tests/e2e/playwright.config.ts",
"tests/e2e/content-templates/blocks/**",
@@ -1056,6 +1063,7 @@
"templates/**/*.html",
"sample-data/sample_products.xml",
"tests/e2e/bin/**",
+ "tests/e2e/mu-plugins/**",
"tests/e2e/fixtures/blocks-setup.ts",
"tests/e2e/playwright.config.ts",
"tests/e2e/content-templates/blocks/**",
@@ -1323,6 +1331,7 @@
"changes": [
"sample-data/sample_products.xml",
"tests/e2e/bin/**",
+ "tests/e2e/mu-plugins/**",
"tests/e2e/fixtures/blocks-setup.ts",
"tests/e2e/playwright.config.ts",
"tests/e2e/content-templates/blocks/**",
@@ -1369,6 +1378,7 @@
"changes": [
"sample-data/sample_products.xml",
"tests/e2e/bin/**",
+ "tests/e2e/mu-plugins/**",
"tests/e2e/fixtures/blocks-setup.ts",
"tests/e2e/playwright.config.ts",
"tests/e2e/content-templates/blocks/**",
@@ -1416,6 +1426,7 @@
"changes": [
"sample-data/sample_products.xml",
"tests/e2e/bin/**",
+ "tests/e2e/mu-plugins/**",
"tests/e2e/fixtures/blocks-setup.ts",
"tests/e2e/playwright.config.ts",
"tests/e2e/content-templates/blocks/**",
@@ -1461,6 +1472,7 @@
"changes": [
"sample-data/sample_products.xml",
"tests/e2e/bin/**",
+ "tests/e2e/mu-plugins/**",
"tests/e2e/fixtures/blocks-setup.ts",
"tests/e2e/playwright.config.ts",
"tests/e2e/content-templates/blocks/**",
diff --git a/plugins/woocommerce/tests/e2e/mu-plugins/wp-cli-2-behaviour.php b/plugins/woocommerce/tests/e2e/mu-plugins/wp-cli-2-behaviour.php
new file mode 100644
index 00000000000..8eb2420cc7f
--- /dev/null
+++ b/plugins/woocommerce/tests/e2e/mu-plugins/wp-cli-2-behaviour.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Plugin Name: WooCommerce E2E: WP-CLI 2.x behaviour on WP-CLI 3
+ * Description: Keeps WP-CLI commands in the E2E environment behaving as they did on WP-CLI 2.x.
+ * Version: 1.0.0
+ * Requires PHP: 7.4
+ * Author: WooCommerce
+ *
+ * WP-CLI 3.0 changed two things that break the E2E environment setup. This undoes both, for
+ * WP-CLI requests only.
+ *
+ * 1. Memory limit. WP-CLI 2.x set `memory_limit` to -1; 3.0 doesn't, and the `wordpress:cli` image
+ * has no php.ini, so commands run out of memory at PHP's default 128M. On 2.x this only raises
+ * the limit earlier in bootstrap.
+ *
+ * 2. Setup wizard redirect. Since 3.0, `wp plugin` and `wp theme` run as a wp-admin request. Right
+ * after WooCommerce is activated, the redirect on `admin_init` exits the command with code 0, so
+ * the next plugin or theme activation silently doesn't happen. The `_wc_activation_redirect`
+ * transient is left alone, so browser requests still get the redirect.
+ *
+ * It's a must-use plugin, mounted in .wp-env.e2e.json, so it loads before wp-env activates any plugin.
+ *
+ * @package Automattic\WooCommerce\E2EPlaywright
+ */
+
+declare(strict_types=1);
+
+if ( defined( 'WP_CLI' ) && WP_CLI ) {
+ // phpcs:ignore WordPress.PHP.IniSet.memory_limit_Disallowed -- WP-CLI 2.x did the same for every command.
+ ini_set( 'memory_limit', '-1' );
+
+ add_filter( 'woocommerce_enable_setup_wizard', '__return_false' );
+}