Today I ran into a confusing issue in a LocalWP site: I changed a PHP file inside a symlinked WordPress plugin, but the browser kept showing output from the old version of the file.

It took me a while to figure out what was happening. I used the “super advanced debugging technique” of adding a number before some content displayed in the browser to confirm that my change was not appearing. However, when I changed the plugin version, the update was reflected on the Plugins screen, which meant the plugin folder symlink was correct.

So I asked Codex CLI inside the project folder what could be causing the issue. After running a few checks, it pointed out that the most likely cause was OPcache and suggested restarting the server (nginx). After doing that, I saw the updated changes in the browser.

To avoid this happening again, it recommended changing the PHP configuration file. In my case, it was located at SITE-FOLDER/conf/php/php.ini.hbs. I replaced:

opcache.enable=1
opcache.enable_cli=1

with:

opcache.enable=1
opcache.enable_cli=0
opcache.validate_timestamps=1
opcache.revalidate_freq=0

This keeps OPcache enabled, but makes PHP check file timestamps on every request so edits show up immediately.

After making this change, I restarted the LocalWP site and the problem was solved.

I’m using Ubuntu Linux, but this issue can also happen on Windows or macOS.



Comments

Leave a Reply

Your email address will not be published. Required fields are marked *