Changeset 61374
- Timestamp:
- 12/13/2025 08:10:50 PM (12 days ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-admin/includes/file.php (modified) (2 diffs)
-
tests/phpunit/tests/filesystem/unzipFilePclzip.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r60309 r61374 1897 1897 1898 1898 // Determine any children directories needed (From within the archive). 1899 foreach ( $archive_files as $ file ) {1900 if ( str_starts_with( $ file['filename'], '__MACOSX/' ) ) { // Skip the OS X-created __MACOSX directory.1899 foreach ( $archive_files as $archive_file ) { 1900 if ( str_starts_with( $archive_file['filename'], '__MACOSX/' ) ) { // Skip the OS X-created __MACOSX directory. 1901 1901 continue; 1902 1902 } 1903 1903 1904 $uncompressed_size += $ file['size'];1905 1906 $needed_dirs[] = $to . untrailingslashit( $ file['folder'] ? $file['filename'] : dirname( $file['filename'] ) );1904 $uncompressed_size += $archive_file['size']; 1905 1906 $needed_dirs[] = $to . untrailingslashit( $archive_file['folder'] ? $archive_file['filename'] : dirname( $archive_file['filename'] ) ); 1907 1907 } 1908 1908 … … 1968 1968 1969 1969 // Extract the files from the zip. 1970 foreach ( $archive_files as $ file ) {1971 if ( $ file['folder'] ) {1970 foreach ( $archive_files as $archive_file ) { 1971 if ( $archive_file['folder'] ) { 1972 1972 continue; 1973 1973 } 1974 1975 if ( str_starts_with( $ file['filename'], '__MACOSX/' ) ) { // Don't extract the OS X-created __MACOSX directory files.1974 1975 if ( str_starts_with( $archive_file['filename'], '__MACOSX/' ) ) { // Don't extract the OS X-created __MACOSX directory files. 1976 1976 continue; 1977 1977 } 1978 1978 1979 1979 // Don't extract invalid files: 1980 if ( 0 !== validate_file( $ file['filename'] ) ) {1980 if ( 0 !== validate_file( $archive_file['filename'] ) ) { 1981 1981 continue; 1982 1982 } 1983 1983 1984 if ( ! $wp_filesystem->put_contents( $to . $ file['filename'], $file['content'], FS_CHMOD_FILE ) ) {1985 return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $ file['filename'] );1984 if ( ! $wp_filesystem->put_contents( $to . $archive_file['filename'], $archive_file['content'], FS_CHMOD_FILE ) ) { 1985 return new WP_Error( 'copy_failed_pclzip', __( 'Could not copy file.' ), $archive_file['filename'] ); 1986 1986 } 1987 1987 } -
trunk/tests/phpunit/tests/filesystem/unzipFilePclzip.php
r61212 r61374 38 38 public function test_should_apply_pre_unzip_file_filters() { 39 39 $filter = new MockAction(); 40 add_filter( 'pre_unzip_file', array( $filter, 'filter' ) );40 add_filter( 'pre_unzip_file', array( $filter, 'filter' ), 10, 2 ); 41 41 42 42 // Prepare test environment. … … 54 54 $this->delete_folders( $unzip_destination ); 55 55 56 $this->assertSame( 1, $filter->get_call_count() ); 56 $this->assertSame( 1, $filter->get_call_count(), 'The filter should be called once.' ); 57 $this->assertSame( self::$test_data_dir . 'archive.zip', $filter->get_args()[0][1], 'The $file parameter should be correct.' ); 57 58 } 58 59 … … 64 65 public function test_should_apply_unzip_file_filters() { 65 66 $filter = new MockAction(); 66 add_filter( 'unzip_file', array( $filter, 'filter' ) );67 add_filter( 'unzip_file', array( $filter, 'filter' ), 10, 2 ); 67 68 68 69 // Prepare test environment. … … 80 81 $this->delete_folders( $unzip_destination ); 81 82 82 $this->assertSame( 1, $filter->get_call_count() ); 83 $this->assertSame( 1, $filter->get_call_count(), 'The filter should be called once.' ); 84 $this->assertSame( self::$test_data_dir . 'archive.zip', $filter->get_args()[0][1], 'The $file parameter should be correct.' ); 83 85 } 84 86 }
Note: See TracChangeset
for help on using the changeset viewer.