From 3248b979975ebda31ca7316a7a7dc36da05c8d72 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Thu, 29 Mar 2018 13:07:11 -0700 Subject: [PATCH] Reverted zip changes while adding extra details about unzip failure --- system/src/Grav/Common/GPM/Installer.php | 63 ++++++++++++++---------- 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php index 819806bfd..6c385b8d8 100644 --- a/system/src/Grav/Common/GPM/Installer.php +++ b/system/src/Grav/Common/GPM/Installer.php @@ -43,6 +43,11 @@ class Installer */ protected static $error = 0; + /** + * @var integer Zip Error Code + */ + protected static $error_zip = 0; + /** * @var string Post install message */ @@ -189,7 +194,8 @@ class Installer return $extracted_folder; } - self::$error = $archive; + self::$error = self::ZIP_EXTRACT_ERROR; + self::$error_zip = $archive; return false; } @@ -459,39 +465,42 @@ class Installer break; case self::ZIP_EXTRACT_ERROR: - $msg = 'An error occurred while extracting the package'; - break; + $msg = 'Unable to extract the package. '; + if (self::$error_zip) { + switch(self::$error_zip) { + case \ZipArchive::ER_EXISTS: + $msg .= "File already exists."; + break; - case \ZipArchive::ER_EXISTS: - $msg = "File already exists."; - break; + case \ZipArchive::ER_INCONS: + $msg .= "Zip archive inconsistent."; + break; - case \ZipArchive::ER_INCONS: - $msg = "Zip archive inconsistent."; - break; + case \ZipArchive::ER_MEMORY: + $msg .= "Malloc failure."; + break; - case \ZipArchive::ER_MEMORY: - $msg = "Malloc failure."; - break; + case \ZipArchive::ER_NOENT: + $msg .= "No such file."; + break; - case \ZipArchive::ER_NOENT: - $msg = "No such file."; - break; + case \ZipArchive::ER_NOZIP: + $msg .= "Not a zip archive."; + break; - case \ZipArchive::ER_NOZIP: - $msg = "Not a zip archive."; - break; + case \ZipArchive::ER_OPEN: + $msg .= "Can't open file."; + break; - case \ZipArchive::ER_OPEN: - $msg = "Can't open file."; - break; + case \ZipArchive::ER_READ: + $msg .= "Read error."; + break; - case \ZipArchive::ER_READ: - $msg = "Read error."; - break; - - case \ZipArchive::ER_SEEK: - $msg = "Seek error."; + case \ZipArchive::ER_SEEK: + $msg .= "Seek error."; + break; + } + } break; default: