WP-CLI 3.0: the activation redirect silently ends the next `wp plugin` / `wp theme` command
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
issueで言及されている有効化後のリダイレクトである inc/admin.php の Admin::maybe_redirect() から始め、リダイレクトフラグの読み取り方とクリア方法を確認します。issueにある2つのWP-CLIコマンドで再現し、そこに記載された早期リターンを追加して、次のコマンドが実行され、最初のwp-adminページではリダイレクトが引き続き機能することを確認します。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- PHP
- スター
- 75
- フォーク
- 14
- 平均マージ
- 1日 6時間
- マージ済み PR(30日)
- 31
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Codeinwp/optimole-wp のほかの issue
-
bug-report bug-report-triage customer report
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
Codeinwp/optimole-wp#1255 ·
メンテナーはふだん 1 日以内に返信
-
Lazyload SVG placeholder runs uncached attachment lookups with JSON-escaped URLs on REST responsesオープンcustomer report
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Codeinwp/optimole-wp#1253 ·
メンテナーはふだん 1 日以内に返信
-
customer report feature-request-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Codeinwp/optimole-wp#1239 ·
メンテナーはふだん 1 日以内に返信
-
Throttle and optimize `/wp-json/optml/v1/optimizations` REST API endpoint execution and validationオープンcustomer report feature-request-triage
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
Codeinwp/optimole-wp#1250 ·
メンテナーはふだん 1 日以内に返信
-
Cache `attachment_url_to_postid()` lookups in `Optml_Lazyload_Replacer` to reduce database overheadオープンcustomer report feature-request-triage
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
Codeinwp/optimole-wp#1249 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
Codeinwp/optimole-wp の issue をすべて見る