Ticket #36455: 36455.12.diff
| File 36455.12.diff, 3.8 KB (added by , 6 years ago) |
|---|
-
src/wp-admin/includes/file.php
diff --git src/wp-admin/includes/file.php src/wp-admin/includes/file.php index cca39895bab..e997b7d2b65 100644
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 ); 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 the opcode cache for an individual PHP file. 2279 * 2280 * This function can be called safely without having to check the file extension 2281 * or availability of the OPcache extension. 2282 * 2283 * Whether or not invalidation is possible is cached to improve performance. 2284 * 2285 * See https://www.php.net/manual/en/function.opcache-invalidate.php for more details. 2286 * 2287 * @since 5.5 2288 * 2289 * @param string $filepath Path to the file, including extension, for which the opcode cache is to be cleared. 2290 * @param bool $force Invalidate even if the modification time is not newer than the file in cache. Default false. 2291 * 2292 * @return bool True if opcache was invalidated for `$filepath`. Default false. 2293 */ 2294 function wp_opcache_invalidate( $filepath, $force = false ) { 2295 static $can_invalidate = null; 2296 2297 // Verify that file to be invalidated has a PHP-related extension. 2298 if ( ! preg_match( '/\.(?:php|phtml)/i', $filepath ) ) { 2299 return false; 2300 } 2301 2302 // Check to see if WordPress is able to run `opcache_invalidate()` or not, and cache the value. 2303 if ( $can_invalidate === null ) { 2304 $can_invalidate = function_exists( 'opcache_invalidate' ) && 2305 ! ini_get( 'opcache.restrict_api' ) || stripos( __FILE__, ini_get( 'opcache.restrict_api' ) ) === 0; 2306 } 2307 2308 // If invalidation is not available, return early. 2309 if ( ! $can_invalidate ) { 2310 return false; 2311 } 2312 2313 /** 2314 * Filters whether to invalidate a file from the opcode cache. 2315 * 2316 * @since 5.5 2317 * 2318 * @param bool $will_invalidate Whether WordPress will invalidate `$filename`. Default `true`. 2319 * @param string $filename The PHP filename to invalidate. 2320 */ 2321 if ( apply_filters( 'wp_opcache_invalidate_file', true, $filepath ) ) { 2322 return opcache_invalidate( $filepath, $force ); 2323 } 2324 2325 return false; 2326 } -
src/wp-admin/includes/update-core.php
diff --git src/wp-admin/includes/update-core.php src/wp-admin/includes/update-core.php index 595ebc053a8..0fe76de8347 100644
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 ) ) {