use wcf\system\WCFACP;
use wcf\util\FileUtil;
use wcf\util\StringUtil;
+use wcf\system\package\validation\PackageValidationException;
/**
* Shows the package install and update form.
throw new UserInputException('uploadPackage', 'uploadFailed');
}
- PackageValidationManager::getInstance()->validate($this->uploadPackage['name'], false);
+ if (!PackageValidationManager::getInstance()->validate($this->uploadPackage['name'], 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('uploadPackage', 'noValidPackage');
+ break;
+ }
+ }
+ }
+
$this->package = PackageValidationManager::getInstance()->getPackageValidationArchive()->getPackage();
}
return '';
}
+ /**
+ * Recursively traverses the package validation archives and returns the first exception.
+ *
+ * @return \Exception
+ */
+ public function getException() {
+ foreach ($this->getPackageValidationArchiveList() as $packageArchive) {
+ if ($packageArchive->getException() !== null) {
+ return $packageArchive->getException();
+ }
+ }
+
+ return null;
+ }
+
/**
* Validates an instruction against the corresponding package installation plugin.
*