Make WordPress Core

Ticket #17301: 17301.1.diff

File 17301.1.diff, 3.4 KB (added by pbiron, 3 years ago)

refreshing patch

  • src/wp-admin/includes/file.php

    From 27a8bddb6651d901de67c275626282ec7d0dfc19 Mon Sep 17 00:00:00 2001
    From: Paul Biron <paul@sparrowhawkcomputing.com>
    Date: Wed, 5 May 2021 18:50:59 -0600
    Subject: [PATCH] Refresh patch so that it cleanly applies.
    
    ---
     src/wp-admin/includes/file.php        | 42 +++++++++++++++++++++++++++
     src/wp-admin/includes/update-core.php |  2 ++
     2 files changed, 44 insertions(+)
    
    diff --git a/src/wp-admin/includes/file.php b/src/wp-admin/includes/file.php
    index 97cef303c1..274f93539b 100644
    a b function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) { 
    16211621                        continue;
    16221622                }
    16231623
     1624                do_action( 'keepalive_tick' );
     1625
    16241626                $parent_folder = dirname( $dir );
    16251627
    16261628                while ( ! empty( $parent_folder )
    function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) { 
    16581660                        continue;
    16591661                }
    16601662
     1663                do_action( 'keepalive_tick' );
     1664
    16611665                // Don't extract invalid files:
    16621666                if ( 0 !== validate_file( $info['name'] ) ) {
    16631667                        continue;
    function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) { 
    17771781
    17781782        // Create those directories if need be:
    17791783        foreach ( $needed_dirs as $_dir ) {
     1784                do_action( 'keepalive_tick' );
     1785
    17801786                // Only check to see if the dir exists upon creation failure. Less I/O this way.
    17811787                if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
    17821788                        return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) );
    function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) { 
    17991805                        continue;
    18001806                }
    18011807
     1808                do_action( 'keepalive_tick' );
     1809
    18021810                if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE ) ) {
    18031811                        return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] );
    18041812                }
    function copy_dir( $from, $to, $skip_list = array() ) { 
    18391847                        continue;
    18401848                }
    18411849
     1850                do_action( 'keepalive_tick' );
     1851
    18421852                if ( 'f' === $fileinfo['type'] ) {
    18431853                        if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
    18441854                                // If copy failed, chmod file to 0644 and try again.
    function wp_opcache_invalidate( $filepath, $force = false ) { 
    24812491
    24822492        return false;
    24832493}
     2494
     2495/**
     2496 * Output dummy data to keep connection open during long-running operations.
     2497 *
     2498 * @since 5.8.0
     2499 */
     2500function connection_keepalive() {
     2501        if ( ! headers_sent() ) {
     2502                return;
     2503        }
     2504
     2505        static $last_sent;
     2506
     2507        if ( ! isset( $last_sent ) ) {
     2508                $last_sent = time();
     2509        }
     2510
     2511        // Only send every 10 seconds
     2512        if ( $last_sent + 10 > time() ) {
     2513                return;
     2514        }
     2515
     2516        $last_sent = time();
     2517
     2518        if ( DOING_AJAX ) {
     2519                echo ' '; // It might be JSON, which doesn't allow comments
     2520        } else {
     2521                echo "<!-- $last_sent -->";
     2522        }
     2523}
     2524
     2525add_action( 'keepalive_tick', 'connection_keepalive' );
  • 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 37c2c287a4..8a17614c1f 100644
    a b function _copy_dir( $from, $to, $skip_list = array() ) { 
    14551455                        continue;
    14561456                }
    14571457
     1458                do_action( 'keepalive_tick' );
     1459
    14581460                if ( 'f' === $fileinfo['type'] ) {
    14591461                        if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) {
    14601462                                // If copy failed, chmod file to 0644 and try again.