opcache invalidation
Assessment
This issue has not been assessed yet.
Description
Bug Report
- Yes, I reviewed the contribution guidelines.
- Yes, more specifically, I reviewed the guidelines on how to write clear bug reports.
Describe the current, buggy behavior
wp plugin update doesn't invalidate PHP-FPM opcache
Describe how other contributors can replicate this bug
wp eval "wp_remote_get(<something returning a plugin version>);"wp plugin update <said-plugin>wp eval "wp_remote_get(<something returning a plugin version>);"
Describe what you would expect as the correct outcome
Output should have changed because the opcache for this script should have been invalidated.
Actual: It's the same output
Let us know what environment you are running this on
wp-cli 2.10.0 on PHP (cli/fpm) 8.2
Provide additional context/Screenshots
wp plugin updateis run in the context of thecliPHP SAPI- It makes use of
Plugin_Upgrader(wp-admin/includes/class-plugin-upgrader.php) - This one has a
wp_clean_plugins_cachetaking care of transients. - and call
install_packagedefined bywp-admin/includes/class-wp-upgrader.php - which makes use of
move_dirwhich... - calls
wp_opcache_invalidate_directory
The problem is that this call is done in the context of the PHP SAPI instead of the PHP-FPM cgi PHP SAPI.
This issue was anticipated in this comment 5 years ago https://core.trac.wordpress.org/ticket/36455#comment:104
Provide a possible solution
https://github.com/gordalina/cachetool/ connects to the fcgi socket to operate on the correct SAPI. I could run the script by hand to invalidate a specific list of files/dir. But wp plugin update must then return the actual list of files which were modified/added/removed (a helper could exist for that purpose), so that the list could be passed on when wp plugin update finishes.
(But something smarter may exist, like hitting a REST API endpoint which runs the adequate wp_opcache_invalidate_directory(), to be requested after the plugins are updated like move_dir would have done?)
- Dominant language
- Gherkin
- Stars
- 90
- Forks
- 88
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 6
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from wp-cli/extension-command
-
command:plugin-update command:theme-update
Difficulty 4/5 3-5 days Newbie friendliness 48/100
wp-cli/extension-command#555 ·
-
bug command:plugin-update state:unconfirmed
Difficulty 4/5 3-5 days Newbie friendliness 48/100
wp-cli/extension-command#548 · 2 comments ·
-
command:theme state:unconfirmed
wp-cli/extension-command#392 · 9 comments · 1 reaction · 2 assignees ·