Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#50354 closed enhancement (fixed)

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

Reported by: nextendweb's profile nextendweb Owned by: kirasong's profile kirasong
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
4 years ago

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

#2 follow-up: @kirasong
4 years 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 years 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 @kirasong
4 years 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 years ago

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