From: Alexander Ebert Date: Fri, 11 Apr 2014 19:36:26 +0000 (+0200) Subject: Some more updates X-Git-Tag: 2.1.0_Alpha_1~904 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=51654676fe6672627ca6fd356cd26c7920543f53;p=GitHub%2FWoltLab%2FWCF.git Some more updates --- diff --git a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php index 9173777c7a..a3da2c78ac 100755 --- a/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PackageStartInstallForm.class.php @@ -7,13 +7,13 @@ use wcf\form\AbstractForm; use wcf\system\exception\PermissionDeniedException; use wcf\system\exception\SystemException; use wcf\system\exception\UserInputException; +use wcf\system\package\validation\PackageValidationManager; use wcf\system\package\PackageArchive; use wcf\system\package\PackageInstallationDispatcher; use wcf\system\WCF; use wcf\system\WCFACP; use wcf\util\FileUtil; use wcf\util\StringUtil; -use wcf\system\package\validation\PackageValidationManager; /** * Shows the package install and update form. @@ -137,7 +137,7 @@ class PackageStartInstallForm extends AbstractForm { throw new UserInputException('uploadPackage', 'uploadFailed'); } - if (PackageValidationManager::getInstance()->validate($this->uploadPackage['name'])) { + if (PackageValidationManager::getInstance()->validate($this->uploadPackage['name'], false)) { die("win"); } else { diff --git a/wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php b/wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php index f1445711a3..b9825fec3c 100644 --- a/wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php @@ -1,9 +1,8 @@ archive->openArchive(); @@ -71,18 +72,31 @@ class PackageValidationArchive implements \RecursiveIterator { if ($deepInspection) { try { + PackageValidationManager::getInstance()->addVirtualPackage($this->archive->getPackageInfo('name'), $this->archive->getPackageInfo('version')); + // check for exclusions - $this->validateExclusion(); + if (true || WCF_VERSION != '2.1.0 Alpha 1 (Typhoon)') { + $this->validateExclusion(); + } // traverse open requirements foreach ($this->archive->getOpenRequirements() as $requirement) { + if (empty($requirement['file'])) { + throw new PackageValidationException(PackageValidationException::MISSING_REQUIREMENT, array( + 'packageName' => $requirement['name'], + 'packageVersion' => $requirement['minversion'] + )); + } + $archive = $this->archive->extractTar($requirement->file); - + $index = count($this->children); $this->children[$index] = new PackageValidationArchive($archive); - if (!$this->children[$index]->validate(true)) { + if (!$this->children[$index]->validate(true, $requirement['minversion'])) { return false; } + + PackageValidationManager::getInstance()->addVirtualPackage($this->archive->getPackageInfo('name'), $this->archive->getPackageInfo('version')); } } catch (PackageValidationException $e) { @@ -99,6 +113,15 @@ class PackageValidationArchive implements \RecursiveIterator { protected function validateInstructions($requiredVersion) { $package = PackageCache::getInstance()->getPackageByIdentifier($this->archive->getPackageInfo('name')); + // delivered package does not provide the minimum required version + if (Package::compareVersion($requiredVersion, $this->archive->getPackageInfo('version'), '>')) { + throw new PackageValidationException(PackageValidationException::INSUFFICIENT_VERSION,array( + 'packageName' => $package->packageName, + 'packageVersion' => $package->packageVersion, + 'deliveredPackageVersion' => $this->archive->getPackageInfo('version') + )); + } + // package is not installed yet if ($package === null) { if (empty($this->archive->getInstallInstructions())) { diff --git a/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php b/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php index e2177c9229..7484cc8daf 100644 --- a/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php +++ b/wcfsetup/install/files/lib/system/package/validation/PackageValidationException.class.php @@ -70,6 +70,12 @@ class PackageValidationException extends SystemException { */ const EXCLUDED_PACKAGES = 8; + /** + * package version is lower than the request version, expects the details 'packageName', 'packageVersion' and 'deliveredPackageVersion' + * @var integer + */ + const INSUFFICIENT_VERSION = 9; + /** * Creates a new PackageArchiveValidationException. * diff --git a/wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php b/wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php index d469bbf4ef..4e679eaed4 100644 --- a/wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php +++ b/wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php @@ -27,12 +27,16 @@ class PackageValidationManager extends SingletonFactory { protected $virtualPackageList = array(); /** - * Validates given archive for existance and ability to be installed/updated + * Validates given archive for existance and ability to be installed/updated. If you set the + * second parameter $deepInspection to "false", the system will only check if the archive + * looks fine, this is useful for a rough check during upload when a more detailed check will + * be performed afterwards. * * @param string $archive + * @param boolean $deepInspection * @return boolean */ - public function validate($archive) { + public function validate($archive, $deepInspection = true) { $this->virtualPackageList = array(); $this->packageValidationArchive = new PackageValidationArchive($archive);