WP-CLI 3.0: the activation redirect silently ends the next `wp plugin` / `wp theme` command

Aperta Adatta ai principianti
#325 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php, wordpress
Ambito
backend, cli

Direzione di ricerca

Inizia da hyve-lite.php, nella closure admin_init che legge hyve_lite_activation_redirect e che è collegata nell’issue. Controlla come si comporta il reindirizzamento durante i comandi WP-CLI, quindi riproduci il problema con i due comandi mostrati nell’issue dopo aver attivato Hyve Lite. Il lavoro è completato quando il reindirizzamento continua a funzionare sulla prima pagina wp-admin mentre il comando WP-CLI successivo viene eseguito normalmente e svolge la propria azione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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. Hyve Lite's one-time redirect after activation, the admin_init closure that reads hyve_lite_activation_redirect (https://github.com/Codeinwp/hyve-lite/blob/6f59ba74c9de2c5d503d3427a0d39e8ba981564f/hyve-lite.php#L80), 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 Hyve Lite ends with exit code 0, no output, and having done nothing.

A deploy or provisioning script that activates Hyve Lite 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 hyve-lite
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 Hyve Lite: 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.

Its current_user_can( 'manage_options' ) check does not help: WP-CLI 3.0 runs these commands as an administrator. The transient lasts 30 seconds, so only a command run within 30 seconds of the activation is affected, which is exactly what a script does.

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
Lingua principale
PHP
Stelle
1
Fork
2
Merge medio
3g 8h
PR unite (30g)
12

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Codeinwp/hyve-lite

Tutte le issue di Codeinwp/hyve-lite

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.