Pārlūkot izejas kodu

Check exception code only if class ZipArchive exists

If is for example exception throwed when downloading tar archive on system without installed zip extension, PHP hangs on fatal error " Class 'ZipArchive' not found".
Jakub Onderka 11 gadi atpakaļ
vecāks
revīzija
afc9069771
1 mainītis faili ar 1 papildinājumiem un 1 dzēšanām
  1. 1 1
      src/Composer/Downloader/ArchiveDownloader.php

+ 1 - 1
src/Composer/Downloader/ArchiveDownloader.php

@@ -69,7 +69,7 @@ abstract class ArchiveDownloader extends FileDownloader
                 $this->filesystem->removeDirectory($temporaryDir);
 
                 // retry downloading if we have an invalid zip file
-                if ($retries && $e instanceof \UnexpectedValueException && $e->getCode() === \ZipArchive::ER_NOZIP) {
+                if ($retries && $e instanceof \UnexpectedValueException && class_exists('ZipArchive') && $e->getCode() === \ZipArchive::ER_NOZIP) {
                     $this->io->write('    Invalid zip file, retrying...');
                     usleep(500000);
                     continue;