diff --git a/administrator/components/com_installer/models/install.php b/administrator/components/com_installer/models/install.php index 4343631474d9d..3c67accc19b7a 100644 --- a/administrator/components/com_installer/models/install.php +++ b/administrator/components/com_installer/models/install.php @@ -92,9 +92,10 @@ public function install() return false; } + $installType = $app->input->getWord('installtype'); if ($package === null) { - switch ($app->input->getWord('installtype')) + switch ($installType) { case 'folder': // Remember the 'Install from Directory' path. @@ -127,12 +128,22 @@ public function install() } elseif (in_array(false, $results, true)) { + if (in_array($installType, array('upload', 'url'))) + { + JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); + } + return false; } // Was the package unpacked? - if (!$package) + if (!$package || !$package['type']) { + if (in_array($installType, array('upload', 'url'))) + { + JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); + } + $app->setUserState('com_installer.message', JText::_('COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE')); return false; } @@ -226,7 +237,7 @@ protected function _getPackageFromUpload() JFile::upload($tmp_src, $tmp_dest); // Unpack the downloaded package file - $package = JInstallerHelper::unpack($tmp_dest); + $package = JInstallerHelper::unpack($tmp_dest, true); return $package; } @@ -260,7 +271,6 @@ protected function _getPackageFromFolder() if (!$type) { JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_PATH_DOES_NOT_HAVE_A_VALID_PACKAGE')); - return false; } $package['packagefile'] = null; @@ -303,6 +313,7 @@ protected function _getPackageFromUrl() { $url = $package_url; } + unset($update); } // Download the package at the URL given @@ -319,7 +330,7 @@ protected function _getPackageFromUrl() $tmp_dest = $config->get('tmp_path'); // Unpack the downloaded package file - $package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file); + $package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file, true); return $package; } diff --git a/libraries/cms/installer/helper.php b/libraries/cms/installer/helper.php index 90f13c8c239bc..6dd4f2e3cb526 100644 --- a/libraries/cms/installer/helper.php +++ b/libraries/cms/installer/helper.php @@ -91,13 +91,14 @@ public static function downloadPackage($url, $target = false) * Unpacks a file and verifies it as a Joomla element package * Supports .gz .tar .tar.gz and .zip * - * @param string $p_filename The uploaded package filename or install directory + * @param string $p_filename The uploaded package filename or install directory + * @param boolean $alwaysReturnArray If should return false (and leave garbage behind) or return $retval['type']=false * * @return mixed Array on success or boolean false on failure * * @since 3.1 */ - public static function unpack($p_filename) + public static function unpack($p_filename, $alwaysReturnArray = false) { // Path to the archive $archivename = $p_filename; @@ -116,6 +117,14 @@ public static function unpack($p_filename) } catch (Exception $e) { + if ($alwaysReturnArray) + { + $retval['extractdir'] = null; + $retval['packagefile'] = $archivename; + $retval['type'] = false; + return $retval; + } + return false; } @@ -155,7 +164,7 @@ public static function unpack($p_filename) */ $retval['type'] = self::detectType($extractdir); - if ($retval['type']) + if ($retval['type'] || $alwaysReturnArray) { return $retval; } @@ -252,7 +261,7 @@ public static function cleanupInstall($package, $resultdir) $config = JFactory::getConfig(); // Does the unpacked extension directory exist? - if (is_dir($resultdir)) + if ($resultdir && is_dir($resultdir)) { JFolder::delete($resultdir); }