opcache invalidation

Open
#444 10 comments 1 reaction 2 assignees View on GitHub

@swissspidy is already working on this.

Since Feb 14, 2026.

  • #501 by @copilot-swe-agent — open

Assessment

This issue has not been assessed yet.

Description

command:plugin-update command:theme-update

Bug Report

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 update is run in the context of the cli PHP SAPI
  • It makes use of Plugin_Upgrader (wp-admin/includes/class-plugin-upgrader.php)
  • This one has a wp_clean_plugins_cache taking care of transients.
  • and call install_package defined by wp-admin/includes/class-wp-upgrader.php
  • which makes use of move_dir which...
  • 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from wp-cli/extension-command

All issues in wp-cli/extension-command

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.