diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php
index cca39895ba..2ba391492b 100644
|
a
|
b
|
function wp_edit_theme_plugin_file( $args ) { |
| 498 | 498 | if ( false === $written ) { |
| 499 | 499 | return new WP_Error( 'unable_to_write', __( 'Unable to write to file.' ) ); |
| 500 | 500 | } |
| 501 | | if ( 'php' === $extension && function_exists( 'opcache_invalidate' ) ) { |
| 502 | | opcache_invalidate( $real_file, true ); |
| 503 | | } |
| | 501 | wp_opcache_invalidate( $real_file, true ); |
| 504 | 502 | |
| 505 | 503 | if ( $is_active && 'php' === $extension ) { |
| 506 | 504 | |
| … |
… |
function wp_edit_theme_plugin_file( $args ) { |
| 608 | 606 | |
| 609 | 607 | // Roll-back file change. |
| 610 | 608 | file_put_contents( $real_file, $previous_content ); |
| 611 | | if ( function_exists( 'opcache_invalidate' ) ) { |
| 612 | | opcache_invalidate( $real_file, true ); |
| 613 | | } |
| | 609 | wp_opcache_invalidate( $real_file, true, false); |
| 614 | 610 | |
| 615 | 611 | if ( ! isset( $result['message'] ) ) { |
| 616 | 612 | $message = __( 'Something went wrong.' ); |
| … |
… |
function copy_dir( $from, $to, $skip_list = array() ) { |
| 1741 | 1737 | return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename ); |
| 1742 | 1738 | } |
| 1743 | 1739 | } |
| | 1740 | wp_opcache_invalidate( $to . $filename ); |
| 1744 | 1741 | } elseif ( 'd' === $fileinfo['type'] ) { |
| 1745 | 1742 | if ( ! $wp_filesystem->is_dir( $to . $filename ) ) { |
| 1746 | 1743 | if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) { |
| … |
… |
function wp_print_request_filesystem_credentials_modal() { |
| 2276 | 2273 | </div> |
| 2277 | 2274 | <?php |
| 2278 | 2275 | } |
| | 2276 | |
| | 2277 | /** |
| | 2278 | * Attempt to clear opcache if possible and necessary. |
| | 2279 | * |
| | 2280 | * This function can be called safely without having to check the file extension or the availability if the opcache |
| | 2281 | * extension. The results will be cached to improve performance on subsequent calls. |
| | 2282 | * |
| | 2283 | * @since 5.5 |
| | 2284 | * |
| | 2285 | * @param string $filepath Path to the file including the extension to which the opcache is to be cleared. |
| | 2286 | * @param bool $force True if the timestamp validation should be skipped. |
| | 2287 | * @param string $match_pattern A full valid regular expression to match against the file name. If matched, the opcache |
| | 2288 | * will be cleared for that $filepath. The default value checks if $filepath ends with ".php" or ".phtml". |
| | 2289 | * |
| | 2290 | */ |
| | 2291 | function wp_opcache_invalidate( $filepath, $force = false, $match_pattern = '/\.(?:php|phtml)/i' ) { |
| | 2292 | static $trigger = null; |
| | 2293 | if ( $trigger === null ) { |
| | 2294 | $trigger = function_exists( 'opcache_invalidate' ) |
| | 2295 | && ( ! ini_get( 'opcache.validate_timestamps' ) || ini_get( 'opcache.revalidate_freq' ) === "0" ) |
| | 2296 | && apply_filters( 'wp_opcache_invalidate_allowed', true ); |
| | 2297 | } |
| | 2298 | |
| | 2299 | if ( $trigger && ( ! $match_pattern || preg_match( $match_pattern, $filepath ) ) ) { |
| | 2300 | opcache_invalidate( $filepath, $force ); |
| | 2301 | } |
| | 2302 | } |
diff --git a/src/wp-admin/includes/update-core.php b/src/wp-admin/includes/update-core.php
index 595ebc053a..0fe76de834 100644
|
a
|
b
|
function _copy_dir( $from, $to, $skip_list = array() ) { |
| 1352 | 1352 | return new WP_Error( 'copy_failed__copy_dir', __( 'Could not copy file.' ), $to . $filename ); |
| 1353 | 1353 | } |
| 1354 | 1354 | } |
| | 1355 | wp_opcache_invalidate( $to . $filename ); |
| 1355 | 1356 | } elseif ( 'd' === $fileinfo['type'] ) { |
| 1356 | 1357 | if ( ! $wp_filesystem->is_dir( $to . $filename ) ) { |
| 1357 | 1358 | if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) { |