Skip to content

Commit

Permalink
Fix(ZipTask): check if setMtimeIndex is available
Browse files Browse the repository at this point in the history
ZipArchive::setMtimeIndex (PHP >= 8.0.0, PECL zip >= 1.16.0)
  • Loading branch information
leagris committed Apr 29, 2024
1 parent ea5b6e5 commit 323a3a1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Phing/Task/Ext/Archive/ZipTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 323a3a1

Please sign in to comment.