Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WP-CLI を使って version を指定してのアップデートで snow-monkey が削除される #1241

Open
waviaei opened this issue May 26, 2022 · 2 comments
Labels

Comments

@waviaei
Copy link

waviaei commented May 26, 2022

WP-CLI で

$ wp theme update snow-monkey --dry-run
Available theme updates:
+-------------+--------+---------+----------------+
| name | status | version | update_version |
+-------------+--------+---------+----------------+
| snow-monkey | active | 14.3.2 | 17.0.1 |
+-------------+--------+---------+----------------+

でverを確認し、16.x.x へアップデートしたかったので

$ wp theme update snow-monkey --version=16.5.3 --dry-run
Error: --dry-run cannot be used together with --version.

を行いましたが、これは dry-run できなかったので

$ wp theme update snow-monkey --version=16.5.3
Warning: snow-monkey: Theme not found
Error: No themes installed.

を行ったところ、 Theme not found とでてきました。

$ wp theme list
+-----------------+----------+-----------+---------+---------+
| name | status | update | version | enabled |
+-----------------+----------+-----------+---------+---------+
| twentytwentytwo | inactive | available | 1.1 | no |
+-----------------+----------+-----------+---------+---------+

wp theme list で確認しても、管理画面で確認しても、ディレクトリを直接確認しても、snow-monkey/ は削除されていました。

CLIでversionを指定してのアップデートで削除されてしまったようです。

CLIを使ってのアップデートにどこかバグがあるのではと思います。

@inc2734
Copy link
Owner

inc2734 commented May 27, 2022

--version を指定しなかったら消えずにアップデートできますか?

@inc2734 inc2734 added the bug label May 27, 2022
@inc2734
Copy link
Owner

inc2734 commented May 31, 2022

バージョン指定があると一旦消すようになっているのかも?
https://github.com/wp-cli/extension-command/blob/master/src/Theme_Command.php#L666

Snow Monkey のアップデートの仕組みは、自作のライブラリを使っていて、WordPress が更新があるか確かめるタイミング(pre_set_site_transient_update_themes)で Snow Monkey 公式サイトのサーバー上にある更新情報を参照し、更新があれば transient に差し込むという流れになっています。
https://github.com/inc2734/wp-github-theme-updater/blob/master/src/App/Model/GitHubReleases.php#L84-L100

公式テーマであれば pre_set_site_transient_update_themes のコールバック関数の引数に公式ディレクトリ上の最新版の情報が入ってくるのですが、自作テーマの場合はそこには空のデータしか返ってこないので、自作の更新情報を参照して transient に差し込むということをしています。

WP-CLI でバージョン指定した場合、このコールバック関数の引数にバージョン情報が入ってくるのかな?と思ったのですが、特にそういうことはなさそうで、バージョン指定したときにどのようなリクエストがどこにきて、どういう処理が走るのかがわかりませんでした。一応自作のライブラリに手を入れようとはしたのですが、そもそも pre_set_site_transient_update_themes は関係なさそうなので、うーん…という感じです。

inc2734 added a commit to inc2734/self-host-github-releases that referenced this issue Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants