WordPress.org

Make WordPress Core

Ticket #36455: 36455.9.diff

File 36455.9.diff, 2.2 KB (added by williampatton, 2 months ago)
  • src/wp-admin/includes/file.php

    diff --git src/wp-admin/includes/file.php src/wp-admin/includes/file.php
    index cca39895ba..5b4146eebb 100644
    function copy_dir( $from, $to, $skip_list = array() ) { 
    17281728        $from = trailingslashit( $from );
    17291729        $to   = trailingslashit( $to );
    17301730
     1731        /**
     1732         * Filters whether to invalidate files in the PHP opcache
     1733         * after it is written during an upgrade.
     1734         *
     1735         * @since 5.5.0
     1736         *
     1737         * @param bool $invalidate Whether to invalidate. Default true.
     1738         */
     1739        $opcache_invalidate_allowed = function_exists( 'opcache_invalidate' ) && apply_filters( 'wp_opcache_invalidate_allowed', true );
     1740
    17311741        foreach ( (array) $dirlist as $filename => $fileinfo ) {
    17321742                if ( in_array( $filename, $skip_list, true ) ) {
    17331743                        continue;
    17341744                }
    17351745
     1746                if ( $opcache_invalidate_allowed && in_array( pathinfo( $filename, PATHINFO_EXTENSION ), array( 'php', 'phtml' ), true ) ) {
     1747                        opcache_invalidate( $to . $filename );
     1748                }
     1749
    17361750                if ( 'f' === $fileinfo['type'] ) {
    17371751                        if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
    17381752                                // If copy failed, chmod file to 0644 and try again.
  • src/wp-admin/includes/update-core.php

    diff --git src/wp-admin/includes/update-core.php src/wp-admin/includes/update-core.php
    index 595ebc053a..1abfd9bb2e 100644
    function _copy_dir( $from, $to, $skip_list = array() ) { 
    13391339        $from = trailingslashit( $from );
    13401340        $to   = trailingslashit( $to );
    13411341
     1342        /** This filter is documented in wp-admin/includes/file.php */
     1343        $opcache_invalidate_allowed = function_exists( 'opcache_invalidate' ) && apply_filters( 'wp_opcache_invalidate_allowed', true );
     1344
    13421345        foreach ( (array) $dirlist as $filename => $fileinfo ) {
    13431346                if ( in_array( $filename, $skip_list, true ) ) {
    13441347                        continue;
    13451348                }
    13461349
     1350                if ( $opcache_invalidate_allowed && in_array( pathinfo( $filename, PATHINFO_EXTENSION ), array( 'php', 'phtml' ), true ) ) {
     1351                        opcache_invalidate( $to . $filename );
     1352                }
     1353
    13471354                if ( 'f' === $fileinfo['type'] ) {
    13481355                        if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
    13491356                                // If copy failed, chmod file to 0644 and try again.