Skip to content

Conversation

@rollybueno
Copy link

This PR adds OPCache information to the Site Health Info page so administrators can see how their PHP OPcache is performing.

The code checks if OPcache is available using extension_loaded('opcache'), then gets detailed status using opcache_get_status(). It displays both user-friendly formatted values and debug information for copying to clipboard. All text is properly internationalized and follows WordPress coding standards.

Trac ticket: https://core.trac.wordpress.org/ticket/63697


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

github-actions bot commented Jul 14, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props rollybueno, westonruter, swissspidy.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this also needs a Site Health test. A site without Opcode Cache should be flagged to users as a performance problem.

'debug' => $opcache_loaded,
);

if ( $opcache_loaded && function_exists( 'opcache_get_status' ) ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these don't exist, then there should be something indicating as such in the data to say that Opcache is not available, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the only data available if that doesn't exists is

jIOr76C

But if that opcache_get_status is exists, we will having this:

fnCmKiG

I can only think of those fields but I'm sure we should come up with agreed set of information first before finalizing the display.

'debug' => $imagick_loaded,
);

// OPCache.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this should be referred to throughout as "Opcode Cache" per https://core.trac.wordpress.org/ticket/63697#comment:2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! - I'll update it together with the labels

@rollybueno
Copy link
Author

If using extension_loaded('opcache'), the result is always false even if it's set to 1. The only time it works is if I use extension_loaded('Zend OPcache'). It's giving mixed results so I'm not sure which one should be more reliable as this could go down per hosting choices.

The question is, should we do a more robust approach by using function_exists( 'opcache_get_status' ) instead and ditch extension_loaded()? This will sacrifice the Is the OPcache extension available? info though.

Hey @westonruter - if you can give advice/opinion, that would be great. Thanks in advance..

@westonruter
Copy link
Member

I haven't done much with Opcode Cache internals, so I don't have a lot to add. But it seems like using function_exists( 'opcache_get_status' ) is best. The specific extension which enables Opcode Cache would be nice to have as additional information, but now it would most likely always be "Zend OPcache". I'm guessing you'd have to have a list of possible such extensions in an array of strings to test for all of them to see if they are available. So I think there would be two entries:

  • Is Opcode Cache enabled?
  • Which Opcode Cache extension is being used?

@rollybueno
Copy link
Author

I think this also needs a Site Health test. A site without Opcode Cache should be flagged to users as a performance problem.

5FEmgZs

Copy link
Member

@westonruter westonruter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on https://core.trac.wordpress.org/ticket/63697#comment:2 any references to "OPcache" should be replaced with "Opcode cache".

There are some merge conflicts with trunk that need to be resolved.

rollybueno and others added 13 commits August 6, 2025 08:48
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Co-authored-by: Weston Ruter <westonruter@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants