Skip to content

Autoloader cache not refreshing #30

@NicoleGeissinger

Description

@NicoleGeissinger

Describe the bug

I found that when the class-loader-cache is created, it isn't refreshing when new (or existing) classes are created/changed. I found instances where my cache was over 2 weeks old despite many changes performed to related classes.

My solve for this was to SFTP into my WP Engine hosted server and manually delete the class-loader-cache directory to ensure it grabs the latest changes.

This results in scenarios of "works locally but not on my servers". I think this issue stems out of iterative deployments. One scenario in my testing, it worked just fine, but it was a server that we hadn't deployed any of the work to yet before any caches were created. If a cache exists and you adjust something in the autoloaded classes, the cache doesn't pick those up.

Ideally there is a mechanism to manually refresh that cache or it auto refreshes when it detects that a class has been modified. I did see the const to skip cache which will be really helpful in debugging this in the future, but ideally we have a reliable source to auto refresh it along with a manual refresh option.

Steps to Reproduce

  1. Create a new class using the ModuleInterface and deploy to your server.
  2. Make some changes that you can observe either from the front or backend (both affected) and deploy.
  3. Double check if your changes can be observed and double check the last modified date of the class-loader-cache and your autoloaded classes.
  4. If the changes aren't showing up due to the cache, deleting the class-loader-cache will fix the issue.

Screenshots, screen recording, code snippet

Image Observe the last modified dates not in alignment. This reflects the effect of the site working in a past state despite all the files being up to date.

Environment information

Myself and another co-worker reported this issue on WP Engine hosted sites so unsure this is relevant at all. There is a thread in the company slack around this.

WordPress information

WordPress 6.8.3

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions