WordPress.org

Make WordPress Core

Ticket #36455: 36455.8.diff

File 36455.8.diff, 2.2 KB (added by nextendweb, 3 months ago)

36455.8.diff

  • wp-admin/includes/file.php

     
    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.4.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.
  • wp-admin/includes/update-core.php

     
    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.