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() ) { |
1621 | 1621 | continue; |
1622 | 1622 | } |
1623 | 1623 | |
| 1624 | do_action( 'keepalive_tick' ); |
| 1625 | |
1624 | 1626 | $parent_folder = dirname( $dir ); |
1625 | 1627 | |
1626 | 1628 | while ( ! empty( $parent_folder ) |
… |
… |
function _unzip_file_ziparchive( $file, $to, $needed_dirs = array() ) { |
1658 | 1660 | continue; |
1659 | 1661 | } |
1660 | 1662 | |
| 1663 | do_action( 'keepalive_tick' ); |
| 1664 | |
1661 | 1665 | // Don't extract invalid files: |
1662 | 1666 | if ( 0 !== validate_file( $info['name'] ) ) { |
1663 | 1667 | continue; |
… |
… |
function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) { |
1777 | 1781 | |
1778 | 1782 | // Create those directories if need be: |
1779 | 1783 | foreach ( $needed_dirs as $_dir ) { |
| 1784 | do_action( 'keepalive_tick' ); |
| 1785 | |
1780 | 1786 | // Only check to see if the dir exists upon creation failure. Less I/O this way. |
1781 | 1787 | if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) { |
1782 | 1788 | return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), substr( $_dir, strlen( $to ) ) ); |
… |
… |
function _unzip_file_pclzip( $file, $to, $needed_dirs = array() ) { |
1799 | 1805 | continue; |
1800 | 1806 | } |
1801 | 1807 | |
| 1808 | do_action( 'keepalive_tick' ); |
| 1809 | |
1802 | 1810 | if ( ! $wp_filesystem->put_contents( $to . $file['filename'], $file['content'], FS_CHMOD_FILE ) ) { |
1803 | 1811 | return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $file['filename'] ); |
1804 | 1812 | } |
… |
… |
function copy_dir( $from, $to, $skip_list = array() ) { |
1839 | 1847 | continue; |
1840 | 1848 | } |
1841 | 1849 | |
| 1850 | do_action( 'keepalive_tick' ); |
| 1851 | |
1842 | 1852 | if ( 'f' === $fileinfo['type'] ) { |
1843 | 1853 | if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) { |
1844 | 1854 | // If copy failed, chmod file to 0644 and try again. |
… |
… |
function wp_opcache_invalidate( $filepath, $force = false ) { |
2481 | 2491 | |
2482 | 2492 | return false; |
2483 | 2493 | } |
| 2494 | |
| 2495 | /** |
| 2496 | * Output dummy data to keep connection open during long-running operations. |
| 2497 | * |
| 2498 | * @since 5.8.0 |
| 2499 | */ |
| 2500 | function 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 | |
| 2525 | add_action( 'keepalive_tick', 'connection_keepalive' ); |
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() ) { |
1455 | 1455 | continue; |
1456 | 1456 | } |
1457 | 1457 | |
| 1458 | do_action( 'keepalive_tick' ); |
| 1459 | |
1458 | 1460 | if ( 'f' === $fileinfo['type'] ) { |
1459 | 1461 | if ( ! $wp_filesystem->copy( $from . $filename, $to . $filename, true, FS_CHMOD_FILE ) ) { |
1460 | 1462 | // If copy failed, chmod file to 0644 and try again. |