Browse Source

Add debugging info for invalid zip files to try and get to the bottom of it, refs #2125

Jordi Boggiano 11 years ago
parent
commit
67407801b8
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/Composer/Downloader/ZipDownloader.php

+ 4 - 0
src/Composer/Downloader/ZipDownloader.php

@@ -68,6 +68,10 @@ class ZipDownloader extends ArchiveDownloader
         $zipArchive = new ZipArchive();
 
         if (true !== ($retval = $zipArchive->open($file))) {
+            if (ZipArchive::ER_NOZIP === $retval) {
+                @copy($file, $copy = sys_get_temp_dir().'/composer-zip-debug.zip');
+                throw new \UnexpectedValueException($this->getErrorMessage($retval, $file).' filesize: '.filesize($file).', file copied to '.$copy.' for debugging, please report this and email us the file if possible');
+            }
             throw new \UnexpectedValueException($this->getErrorMessage($retval, $file));
         }