WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 4 months ago

Last modified 3 months ago

#50354 closed enhancement (fixed)

Call opcache_invalidate() after saving PHP files in Theme/Plugin editor

Reported by: nextendweb Owned by: mikeschroder
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-dev-note
Focuses: Cc:

Description (last modified by SergeyBiryukov)

In Theme Editor and Plugin Editor, you can edit PHP file. After you save such file, there should be an opcache_reset() call on the saved file if its extension matches to .php or .phtml.

opcache_reset related ticket for theme/plugin/core update: #36455

Change History (6)

#1 @SergeyBiryukov
5 months ago

  • Component changed from General to Administration
  • Description modified (diff)

#2 follow-up: @mikeschroder
4 months ago

Hi @nextendweb!

I believe core runs opcache_invalidate() on files that are written with the plugin or theme editors.

The current patch for #36455 replaces those two calls with the new function we're working on there.

Do you think more needs to be done than that?

#3 in reply to: ↑ 2 @nextendweb
4 months ago

  • Summary changed from Call opcache_reset() after saving PHP files in Theme/Plugin editor to Call opcache_invalidate() after saving PHP files in Theme/Plugin editor

Replying to mikeschroder:

Hi @nextendweb!

I believe core runs opcache_invalidate() on files that are written with the plugin or theme editors.

The current patch for #36455 replaces those two calls with the new function we're working on there.

Do you think more needs to be done than that?

Yes, your patch fixes these too.

#4 @mikeschroder
4 months ago

  • Owner set to mikeschroder
  • Resolution set to fixed
  • Status changed from new to closed

In 48160:

Upgrade/Install: Invalidate OPcache for PHP files during updates.

When files are copied into place, check whether opcode invalidation is available and attempt to invalidate to avoid unintended behavior or fatal errors from themes, plugins, or core.

Introduces wp_opcache_invalidate() to allow safe invalidation of PHP files from opcode cache, and a filter, wp_opcache_invalidate_file to override the behavior.

Replaces the existing calls to opcache_invalidate() in the plugin and theme editors to use the new function.

Thanks to jnylen0 for porting over a patch from ClassicPress that provided much of the approach for what is being committed.

Props nigro.simone, dd32, JasWSInc, szepe.viktor, swissspidy, JanR, asalce, Garavani, pavelevap, pputzer, GregLone, benoitchantre, jadonn, doc987, kraftbj, Krstarica, jnylen0, nextendweb, williampatton, ayeshrajans, joostdevalk, stevenkussmaul, boogah, jorbin, mikeschroder.
Fixes #36455, #50354.

#5 @SergeyBiryukov
4 months ago

  • Milestone changed from Awaiting Review to 5.5
Note: See TracTickets for help on using tickets.