From: Sebastian Teumert Date: Sat, 6 Sep 2014 10:24:17 +0000 (+0200) Subject: Fixes #1807 X-Git-Tag: 2.1.0_Alpha_1~322^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=366aaec6f51cb45bb64198e68a3f5cc5cf894414;p=GitHub%2FWoltLab%2FWCF.git Fixes #1807 --- diff --git a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php index f77e4bcf8b..15d1a07d5d 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php @@ -175,69 +175,22 @@ class PackageStartInstallForm extends AbstractForm { if (!file_exists($this->downloadPackage)) { throw new UserInputException('downloadPackage', 'downloadFailed'); } - - $this->archive = new PackageArchive($this->downloadPackage, $this->package); - } - - $this->validateArchive('downloadPackage'); - } - - /** - * Validates the package archive. - * - * @param string $type upload or download package - */ - protected function validateArchive($type) { - // try to open the archive - try { - // TODO: Exceptions thrown within openArchive() are discarded, resulting in - // the meaningless message 'not a valid package' - $this->archive->openArchive(); - } - catch (SystemException $e) { - throw new UserInputException($type, 'noValidPackage'); } - // validate php requirements - $errors = PackageInstallationDispatcher::validatePHPRequirements($this->archive->getPhpRequirements()); - if (!empty($errors)) { - WCF::getTPL()->assign('phpRequirements', $errors); - throw new UserInputException($type, 'phpRequirements'); + if (!PackageValidationManager::getInstance()->validate($this->downloadPackage, false)) { + $exception = PackageValidationManager::getInstance()->getException(); + if ($exception instanceof PackageValidationException) { + switch ($exception->getCode()) { + case PackageValidationException::INVALID_PACKAGE_NAME: + case PackageValidationException::MISSING_PACKAGE_XML: + throw new UserInputException('downloadPackage', 'noValidPackage'); + break; + } + } } - // try to find existing package - $sql = "SELECT * - FROM wcf".WCF_N."_package - WHERE package = ?"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array($this->archive->getPackageInfo('name'))); - $row = $statement->fetchArray(); - if ($row !== false) { - $this->package = new Package(null, $row); - } + $this->package = PackageValidationManager::getInstance()->getPackageValidationArchive()->getPackage(); - // check update or install support - if ($this->package !== null) { - WCF::getSession()->checkPermissions(array('admin.system.package.canUpdatePackage')); - $this->activeMenuItem = 'wcf.acp.menu.link.package'; - - if (!$this->archive->isValidUpdate($this->package)) { - throw new UserInputException($type, 'noValidUpdate'); - } - } - else { - WCF::getSession()->checkPermissions(array('admin.system.package.canInstallPackage')); - - if (!$this->archive->isValidInstall()) { - throw new UserInputException($type, 'noValidInstall'); - } - else if ($this->archive->isAlreadyInstalled()) { - throw new UserInputException($type, 'uniqueAlreadyInstalled'); - } - else if ($this->archive->getPackageInfo('isApplication') && $this->archive->hasUniqueAbbreviation()) { - throw new UserInputException($type, 'noUniqueAbbrevation'); - } - } } /**