WP-CLI 3.0: the activation redirect silently ends the next `wp plugin` / `wp theme` command
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
Piste de recherche
Commencez dans inc/admin.php, au niveau de Admin::maybe_redirect(), la redirection après activation mentionnée dans l’issue, et vérifiez comment elle lit et efface le marqueur de redirection. Reproduisez le problème avec les deux commandes WP-CLI de l’issue, ajoutez ensuite le retour anticipé décrit dans celle-ci et vérifiez que la commande suivante s’exécute tandis que la redirection fonctionne toujours sur la première page wp-admin.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
What happens
WP-CLI 3.0 (stable since 2026-12-01) changed its default context from cli to auto, which runs wp plugin … and wp theme … commands as a wp-admin page load for an administrator, so admin_init fires. Optimole's one-time redirect after activation, Admin::maybe_redirect() (https://github.com/Codeinwp/optimole-wp/blob/31e2a5c8d039998cfd2921544d3655d1878fb316/inc/admin.php#L1137), then calls wp_safe_redirect() and exit. WP-CLI suppresses the redirect header (wp-cli/wp-cli#6279) but not the exit, so the first such command after activating Optimole ends with exit code 0, no output, and having done nothing.
A deploy or provisioning script that activates Optimole and then runs another plugin or theme command silently skips that step: an install that never happens, a theme that is not activated, a deactivation that does not happen, or wp plugin is-installed answering success for a missing plugin. Only one command is affected, because the redirect clears its flag.
Reproduce
wp plugin activate optimole-wp
wp plugin install hello-dolly # WP-CLI 3.0.x: prints nothing, exit 0, nothing installed
Measured on a local WordPress site with the current release of Optimole: under WP-CLI 3.0.1 the wp plugin install above printed nothing, exited 0 and installed nothing; under WP-CLI 2.12.0 the same steps installed the plugin.
Suggested fix
Return before the flag is read or cleared when running under WP-CLI, so the redirect still happens on the administrator's first wp-admin page:
if ( defined( 'WP_CLI' ) && WP_CLI ) {
return;
}
This is how Easy MCP AI fixed the same bug in App_Page::maybe_redirect() (Codeinwp/wp-plugin-easy-mcp@c2ef3e341, with a unit test). Other Codeinwp products were checked the same way; the same issue is open in each affected one:
- Codeinwp/hyve-lite#325
- Codeinwp/optimole-wp#1259
- Codeinwp/otter-blocks#3238
- Codeinwp/redirection-for-contact-form-7#332
- Codeinwp/sparks-for-woocommerce#441
- Codeinwp/templates-patterns-collection#554
- Codeinwp/WP-Cloudflare-Super-Page-Cache#899
- Codeinwp/wp-full-stripe#853
- Codeinwp/wp-maintenance-mode#615
- Langage dominant
- PHP
- Étoiles
- 75
- Forks
- 14
- Merge moyen
- 1 j 6 h
- PR mergées (30 j)
- 31
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de Codeinwp/optimole-wp
-
bug-report bug-report-triage customer report
Difficulté 2/5 1-3 heures Accessibilité débutants 69/100
Codeinwp/optimole-wp#1255 ·
Les mainteneurs répondent en général sous 1 jour
-
Lazyload SVG placeholder runs uncached attachment lookups with JSON-escaped URLs on REST responsesOuvertecustomer report
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Codeinwp/optimole-wp#1253 ·
Les mainteneurs répondent en général sous 1 jour
-
customer report feature-request-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Codeinwp/optimole-wp#1239 ·
Les mainteneurs répondent en général sous 1 jour
-
Throttle and optimize `/wp-json/optml/v1/optimizations` REST API endpoint execution and validationOuvertecustomer report feature-request-triage
Difficulté 3/5 1-2 jours Accessibilité débutants 45/100
Codeinwp/optimole-wp#1250 ·
Les mainteneurs répondent en général sous 1 jour
-
Cache `attachment_url_to_postid()` lookups in `Optml_Lazyload_Replacer` to reduce database overheadOuvertecustomer report feature-request-triage
Difficulté 3/5 1-2 jours Accessibilité débutants 65/100
Codeinwp/optimole-wp#1249 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de Codeinwp/optimole-wp
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
-
repo:ckeditor
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
craftcms/ckeditor#682 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
component/core domain/framework
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 75/100