|
|
@@ -811,6 +811,24 @@ class ZipReader
|
|
|
$chunkSize = 8192;
|
|
|
|
|
|
try {
|
|
|
+ // PHP 8.4+ emits warnings (and PHP 8.5+ notices) from stream filters,
|
|
|
+ // e.g. "fread(): zlib: data error" when a decryption filter produced
|
|
|
+ // garbage. Convert these diagnostics into ZipException so that every
|
|
|
+ // PHP version reports a uniform failure.
|
|
|
+ set_error_handler(
|
|
|
+ static function (int $errorNumber, string $errorString) use ($entry): bool {
|
|
|
+ throw new ZipException(
|
|
|
+ sprintf(
|
|
|
+ 'Error reading the contents of entry "%s". %s',
|
|
|
+ $entry->getName(),
|
|
|
+ $errorString
|
|
|
+ ),
|
|
|
+ $errorNumber
|
|
|
+ );
|
|
|
+ },
|
|
|
+ \E_WARNING | \E_USER_WARNING | \E_NOTICE | \E_USER_NOTICE
|
|
|
+ );
|
|
|
+
|
|
|
if ($skipCheckCrc) {
|
|
|
while ($offset < $limit) {
|
|
|
$length = min($chunkSize, $limit - $offset);
|
|
|
@@ -844,6 +862,8 @@ class ZipReader
|
|
|
}
|
|
|
}
|
|
|
} finally {
|
|
|
+ restore_error_handler();
|
|
|
+
|
|
|
for ($i = \count($filters); $i > 0; $i--) {
|
|
|
stream_filter_remove($filters[$i - 1]);
|
|
|
}
|