Improve error message for missing instruction file (#2305)
authorFabii547 <Fabii547@users.noreply.github.com>
Wed, 14 Jun 2017 12:16:22 +0000 (14:16 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 14 Jun 2017 12:16:22 +0000 (14:16 +0200)
wcfsetup/install/files/lib/system/package/validation/PackageValidationArchive.class.php
wcfsetup/install/files/lib/system/package/validation/PackageValidationManager.class.php

index 9f862923fcf227a61894606f970dc90307fe9555..8c80576e4643bb7280b1d03e4fd5021fb0f4edbe 100644 (file)
@@ -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
                                ]);
                        }
                }
index e284a890c0557574371fd7dceed13ce2a1ffa5cf..f0ed7bc390fbdd720ade2cb93944d778ad4ce40a 100644 (file)
@@ -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;
+       }
 }