Make WordPress Core


Ignore:
Timestamp:
12/13/2025 08:10:50 PM (10 months ago)
Author:
SergeyBiryukov
Message:

Filesystem API: Pass correct $file value to pre_unzip_file and unzip_file filters.

This commit ensures that the original $file argument passed to the function is not unintentionally overwritten by the use of the same variable name in two foreach loops.

Follow-up to [56689].

Props sanchothefat, westonruter, mukesh27, SergeyBiryukov.
Fixes #64398.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/filesystem/unzipFilePclzip.php

    r61212 r61374  
    3838        public function test_should_apply_pre_unzip_file_filters() {
    3939                $filter = new MockAction();
    40                 add_filter( 'pre_unzip_file', array( $filter, 'filter' ) );
     40                add_filter( 'pre_unzip_file', array( $filter, 'filter' ), 10, 2 );
    4141
    4242                // Prepare test environment.
    … …  
    5454                $this->delete_folders( $unzip_destination );
    5555
    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.' );
    5758        }
    5859
    … …  
    6465        public function test_should_apply_unzip_file_filters() {
    6566                $filter = new MockAction();
    66                 add_filter( 'unzip_file', array( $filter, 'filter' ) );
     67                add_filter( 'unzip_file', array( $filter, 'filter' ), 10, 2 );
    6768
    6869                // Prepare test environment.
    … …  
    8081                $this->delete_folders( $unzip_destination );
    8182
    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.' );
    8385        }
    8486}
Note: See TracChangeset for help on using the changeset viewer.