[wp-trac] [WordPress Trac] #36455: Call opcache_reset() after plug-in, theme or core update
WordPress Trac
noreply at wordpress.org
Wed Jun 10 08:21:33 UTC 2020
#36455: Call opcache_reset() after plug-in, theme or core update
-------------------------------------------+---------------------------
Reporter: nigro.simone | Owner: mikeschroder
Type: enhancement | Status: assigned
Priority: normal | Milestone: 5.5
Component: Upgrade/Install | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-testing early | Focuses:
-------------------------------------------+---------------------------
Comment (by ayeshrajans):
I work on a Composer Opcache preload plugin, and personally spend a lot of
time with opcache, and it is quite uncommon to see timestamp-validation
turned off. I believe that if someone the validation off, they must be
aware of the consequences of it.
Regarding the patch, I would like to suggest a few changes and
considerations:
1. Statically cache the result whether opcache should be reset or not.
This prevents applying `wp_opcache_invalidate_allowed` filter and other
`ini_get`/`function_exists` calls over an over.
2. In extension check, a simple regular expression can be nearly 15 times
faster compared to the `in_array(pathinfo())` combo. See a simple
benchmark here: https://3v4l.org/Qv39v
3. If `opcache.validate_timestamps` is set 1, **and**
`opcache.revalidate_freq` set to 0, we do not need to clear opcache for
that file because PHP will need to revalidate opcache by itself on every
request. By default, `opcache.revalidate_freq` is set to 2 seconds.
4. It is unlikely that this is the only case that we need to clear opcache
for a file, so ideally we should create a reusable function to do this
elsewhere in the code. See #50354
5. There are currently 2 `opcache_invalidate` calls in core.
I worked on patch that takes a slightly different approach to address all
5 points above (attached in next comment).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/36455#comment:75>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list