Commit 83f4bd06ac2 for woocommerce
commit 83f4bd06ac27239a2f8a4139c38821a11e204202
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date: Thu Oct 29 14:27:21 2026 +0200
Fix Gutenberg E2E env plugin install on WordPress 7.1.4 (#70371)
diff --git a/plugins/woocommerce/changelog/fix-e2e-gutenberg-install-slug b/plugins/woocommerce/changelog/fix-e2e-gutenberg-install-slug
new file mode 100644
index 00000000000..88921791e6f
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-e2e-gutenberg-install-slug
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Fix the Gutenberg E2E env plugin install on WordPress 7.1.4+; test tooling only, no production change.
diff --git a/plugins/woocommerce/tests/e2e/bin/install-plugin.sh b/plugins/woocommerce/tests/e2e/bin/install-plugin.sh
index d160762cd95..5fe71fa8665 100755
--- a/plugins/woocommerce/tests/e2e/bin/install-plugin.sh
+++ b/plugins/woocommerce/tests/e2e/bin/install-plugin.sh
@@ -23,7 +23,11 @@ wp_cli="pnpm wp-env:e2e run cli"
echo "Installing $PLUGIN_NAME from $PLUGIN_REPOSITORY"
download_url=$( curl -s "https://api.github.com/repos/$PLUGIN_REPOSITORY/releases/latest" | grep browser_download_url | cut -d '"' -f 4 )
-$wp_cli wp plugin install "$download_url" --force --activate || ( sleep 5 && $wp_cli wp plugin install "$download_url" --force --activate )
+# Since WordPress 7.1.4, a zip with no top-level folder installs into a folder with a random suffix.
+# Rename it to $PLUGIN_SLUG. WP-CLI 2.12.0 bundles extension-command 2.1.24; switch to `wp plugin install --slug` once WP-CLI bundles extension-command 2.3.0+.
+rename_to_slug="WP_CLI::add_wp_hook( 'upgrader_source_selection', function ( \$source ) { if ( basename( \$source ) === '$PLUGIN_SLUG' ) { return \$source; } \$target = dirname( \$source ) . '/$PLUGIN_SLUG/'; return \$GLOBALS['wp_filesystem']->move( \$source, \$target, true ) ? \$target : new WP_Error( 'rename_failed', 'Could not rename the plugin folder to $PLUGIN_SLUG.' ); } );"
+install_cmd=( wp plugin install "$download_url" --force --activate "--exec=$rename_to_slug" )
+$wp_cli -- "${install_cmd[@]}" || ( sleep 5 && $wp_cli -- "${install_cmd[@]}" )
$wp_cli wp plugin list
$wp_cli wp plugin is-active "$PLUGIN_SLUG" || ( echo "Plugin \"$PLUGIN_SLUG\" is not active!" && exit 1 )