Make WordPress Core

Opened 5 months ago

Closed 5 months ago

Last modified 5 months ago

#64398 closed defect (bug) (fixed)

`pre_unzip_file` and `unzip_file` filters in `_unzip_file_pclzip()` do not function as documented

Reported by: sanchothefat's profile sanchothefat Owned by: westonruter's profile westonruter
Milestone: 7.0 Priority: normal
Severity: normal Version: trunk
Component: Filesystem API Keywords: has-patch changes-requested
Focuses: Cc:

Description

The filters in _unzip_file_pclzip() have a bug, caused by the use of the variable name $file in 2 foreach loops within the function that overwrite the original argument passed to the function.

trunk/src/wp-admin/includes/file.php#L1963

trunk/src/wp-admin/includes/file.php#L1990

Change History (6)

This ticket was mentioned in PR #10618 on WordPress/wordpress-develop by @sanchothefat.


5 months ago
#1

  • Keywords has-patch added

The foreach loops set the $file variable, overriding the one passed into the function on each iteration, so the filter does not work as documented for _unzip_file_pclzip()

Uses a different variable name in the foreach loops to preserve the $file variable passed to the filter.

Trac ticket: [](https://core.trac.wordpress.org/ticket/64398)

@westonruter commented on PR #10618:


5 months ago
#2

@roborourke looks like the changes broke a related unit test.

#3 @westonruter
5 months ago

  • Milestone changed from Awaiting Review to 7.0
  • Owner set to westonruter
  • Status changed from new to reviewing

#4 @westonruter
5 months ago

  • Keywords changes-requested added

#5 @SergeyBiryukov
5 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 61374:

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.

#6 @westonruter
5 months ago

In 61375:

Coding Standards: Remove whitespace at end of line.

Fixes PHPCS warning: Squiz.WhiteSpace.SuperfluousWhitespace.EndLine.

Follow-up to [61374].

See #64398.

Note: See TracTickets for help on using tickets.