WordPress.org

Make WordPress Core

Ticket #36455: 36455.11-no-timestampcheck.patch

File 36455.11-no-timestampcheck.patch, 3.3 KB (added by ayeshrajans, 2 months ago)
  • src/wp-admin/includes/file.php

    diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php
    index cca39895ba..6a23fae34b 100644
    a b function wp_edit_theme_plugin_file( $args ) { 
    498498        if ( false === $written ) {
    499499                return new WP_Error( 'unable_to_write', __( 'Unable to write to file.' ) );
    500500        }
    501         if ( 'php' === $extension && function_exists( 'opcache_invalidate' ) ) {
    502                 opcache_invalidate( $real_file, true );
    503         }
     501        wp_opcache_invalidate( $real_file, true );
    504502
    505503        if ( $is_active && 'php' === $extension ) {
    506504
    function wp_edit_theme_plugin_file( $args ) { 
    608606
    609607                        // Roll-back file change.
    610608                        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);
    614610
    615611                        if ( ! isset( $result['message'] ) ) {
    616612                                $message = __( 'Something went wrong.' );
    function copy_dir( $from, $to, $skip_list = array() ) { 
    17411737                                        return new WP_Error( 'copy_failed_copy_dir', __( 'Could not copy file.' ), $to . $filename );
    17421738                                }
    17431739                        }
     1740                        wp_opcache_invalidate( $to . $filename );
    17441741                } elseif ( 'd' === $fileinfo['type'] ) {
    17451742                        if ( ! $wp_filesystem->is_dir( $to . $filename ) ) {
    17461743                                if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) {
    function wp_print_request_filesystem_credentials_modal() { 
    22762273        </div>
    22772274        <?php
    22782275}
     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 */
     2291function 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}
  • src/wp-admin/includes/update-core.php

    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() ) { 
    13521352                                        return new WP_Error( 'copy_failed__copy_dir', __( 'Could not copy file.' ), $to . $filename );
    13531353                                }
    13541354                        }
     1355                        wp_opcache_invalidate( $to . $filename );
    13551356                } elseif ( 'd' === $fileinfo['type'] ) {
    13561357                        if ( ! $wp_filesystem->is_dir( $to . $filename ) ) {
    13571358                                if ( ! $wp_filesystem->mkdir( $to . $filename, FS_CHMOD_DIR ) ) {