Changeset 56689
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r56599 r56689 1698 1698 } 1699 1699 1700 // Enough space to unzip the file and copy its contents, with a 10% buffer. 1701 $required_space = $uncompressed_size * 2.1; 1702 1700 1703 /* 1701 1704 * disk_free_space() could return false. Assume that any falsey value is an error. … … 1706 1709 $available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false; 1707 1710 1708 if ( $available_space && ( $ uncompressed_size * 2.1 ) > $available_space) {1711 if ( $available_space && ( $required_space > $available_space ) ) { 1709 1712 return new WP_Error( 1710 1713 'disk_full_unzip_file', … … 1747 1750 } 1748 1751 } 1749 unset( $needed_dirs ); 1752 1753 /** 1754 * Filters archive unzipping to override with a custom process. 1755 * 1756 * @since 6.4.0 1757 * 1758 * @param null|true|WP_Error $result The result of the override. True on success, otherwise WP Error. Default null. 1759 * @param string $file Full path and filename of ZIP archive. 1760 * @param string $to Full path on the filesystem to extract archive to. 1761 * @param string[] $needed_dirs A full list of required folders that need to be created. 1762 * @param float $required_space The space required to unzip the file and copy its contents, with a 10% buffer. 1763 */ 1764 $pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space ); 1765 1766 if ( null !== $pre ) { 1767 // Ensure the ZIP file archive has been closed. 1768 $z->close(); 1769 1770 return $pre; 1771 } 1750 1772 1751 1773 for ( $i = 0; $i < $z->numFiles; $i++ ) { … … 1782 1804 $z->close(); 1783 1805 1784 return true; 1806 /** 1807 * Filters the result of unzipping an archive. 1808 * 1809 * @since 6.4.0 1810 * 1811 * @param true|WP_Error $result The result of unzipping the archive. True on success, otherwise WP_Error. Default true. 1812 * @param string $file Full path and filename of ZIP archive. 1813 * @param string $to Full path on the filesystem the archive was extracted to. 1814 * @param string[] $needed_dirs A full list of required folders that were created. 1815 * @param float $required_space The space required to unzip the file and copy its contents, with a 10% buffer. 1816 */ 1817 $result = apply_filters( 'unzip_file', true, $file, $to, $needed_dirs, $required_space ); 1818 1819 unset( $needed_dirs ); 1820 1821 return $result; 1785 1822 } 1786 1823 … … 1839 1876 } 1840 1877 1878 // Enough space to unzip the file and copy its contents, with a 10% buffer. 1879 $required_space = $uncompressed_size * 2.1; 1880 1841 1881 /* 1842 1882 * disk_free_space() could return false. Assume that any falsey value is an error. … … 1847 1887 $available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false; 1848 1888 1849 if ( $available_space && ( $ uncompressed_size * 2.1 ) > $available_space) {1889 if ( $available_space && ( $required_space > $available_space ) ) { 1850 1890 return new WP_Error( 1851 1891 'disk_full_unzip_file', … … 1888 1928 } 1889 1929 } 1890 unset( $needed_dirs ); 1930 1931 /** This filter is documented in src/wp-admin/includes/file.php */ 1932 $pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space ); 1933 1934 if ( null !== $pre ) { 1935 return $pre; 1936 } 1891 1937 1892 1938 // Extract the files from the zip. … … 1910 1956 } 1911 1957 1912 return true; 1958 /** This action is documented in src/wp-admin/includes/file.php */ 1959 $result = apply_filters( 'unzip_file', true, $file, $to, $needed_dirs, $required_space ); 1960 1961 unset( $needed_dirs ); 1962 1963 return $result; 1913 1964 } 1914 1965
Note: See TracChangeset
for help on using the changeset viewer.