From 87347ffa493b4cbadeec3f975541f94357569e38 Mon Sep 17 00:00:00 2001 From: Fabii547 Date: Wed, 14 Jun 2017 14:16:22 +0200 Subject: [PATCH] Improve error message for missing instruction file (#2305) --- .../PackageValidationArchive.class.php | 4 +++- .../PackageValidationManager.class.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) 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 9f862923fc..8c80576e46 100644 --- a/wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php @@ -247,10 +247,12 @@ class PackageValidationArchive implements \RecursiveIterator { for ($i = 0, $length = count($instructions); $i < $length; $i++) { $instruction = $instructions[$i]; if (!PackageValidationManager::getInstance()->validatePackageInstallationPluginInstruction($this->archive, $instruction['pip'], $instruction['value'])) { + $defaultFilename = PackageValidationManager::getInstance()->getDefaultFilenameForPackageInstallationPlugin($instruction['pip']); + throw new PackageValidationException(PackageValidationException::MISSING_INSTRUCTION_FILE, [ 'pip' => $instruction['pip'], 'type' => $type, - 'value' => $instruction['value'] + 'value' => $instruction['value'] ?: $defaultFilename ]); } } 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 e284a890c0..f0ed7bc390 100644 --- a/wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php +++ b/wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php @@ -188,4 +188,20 @@ class PackageValidationManager extends SingletonFactory { return true; } + + /** + * Returns the default filename for the given pip name. If no default filename + * exists `null` is returned. + * + * @param string $pip + * @return string|null + * @since 3.1 + */ + public function getDefaultFilenameForPackageInstallationPlugin($pip) { + if (isset($this->packageInstallationPlugins[$pip])) { + return call_user_func([$this->packageInstallationPlugins[$pip], 'getDefaultFilename']); + } + + return null; + } } -- 2.20.1