Opened 5 years ago
Closed 5 years ago
#52511 closed enhancement (duplicate)
PclZip throwing error for zero byte files in PHP 8
| Reported by: | arl1nd | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Filesystem API | Version: | |
| Severity: | major | Keywords: | needs-patch |
| Cc: | Focuses: |
Description
Hi there,
As you know, PHP 8 requires file size to be greater than 0 in order to read it. PclZip fails to create an archive when a zero byte file appears in a directory. I think you should fix this issue in:
wp-admin/includes/class-pclzip.php:2677
Change History (3)
#2
@
5 years ago
Thanks @knutsp
Yes that is correct, this happens only when ZipArchive is not available. I've solved this by changing the original code in class-pclzip.php from:
$v_content = @fread($v_file, $p_header['size']);
To:
$v_content = '';
if ( 0 < $p_header['size'] ) {
$v_content = @fread($v_file, $p_header['size']);
}
It would be great if you can add this patch in core trac.
Thanks for fast response.
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Can confirm this - in case PHP zip extension (ZipArchive class) is not loaded. This was a major turn off in an early attempt to upgrade to PHP 8 - later zip became available in my cPanel and "solved" this for me. I guess PclZip is a fallback for ZipArchive.