From 6628edd95355c28283f346490c3f0a1a63476d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Gris?= Date: Mon, 29 Apr 2024 16:46:11 +0200 Subject: [PATCH] Fix(ZipTask): check if setMtimeIndex is available ZipArchive::setMtimeIndex (PHP >= 8.0.0, PECL zip >= 1.16.0) --- src/Phing/Task/Ext/Archive/ZipTask.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Phing/Task/Ext/Archive/ZipTask.php b/src/Phing/Task/Ext/Archive/ZipTask.php index 3e1749a19..4d1755ebe 100644 --- a/src/Phing/Task/Ext/Archive/ZipTask.php +++ b/src/Phing/Task/Ext/Archive/ZipTask.php @@ -88,7 +88,9 @@ private static function fixDirAttributes($zip, $f, $pathInZip) { $indexInZip = $zip->locateName('/' === mb_substr($pathInZip, -1) ? $pathInZip : $pathInZip . '/'); if (false !== $indexInZip) { - $zip->setMtimeIndex($indexInZip, $f->lastModified()); + if (method_exists($zip, 'setMtimeIndex')) { // PHP >= 8.0.0, PECL zip >= 1.16.0 + $zip->setMtimeIndex($indexInZip, $f->lastModified()); + } $filePerms = fileperms($f->getPath()); if (false !== $filePerms) { // filePerms supported $zip->setExternalAttributesIndex($indexInZip, \ZipArchive::OPSYS_DEFAULT, $filePerms << 16); @@ -103,7 +105,7 @@ private static function fixDirAttributes($zip, $f, $pathInZip) private static function clearExternalAttributes($zip) { for ($i = 0, $count = $zip->count(); $i < $count; ++$i) { - $zip->setExternalAttributesIndex($i, \ZipArchive::OPSYS_DOS, null); + $zip->setExternalAttributesIndex($i, \ZipArchive::OPSYS_DOS, 0); } }