Fix installation of application-specific files in dev tools
authorMatthias Schmidt <gravatronics@live.com>
Sun, 16 Jul 2017 13:07:30 +0000 (15:07 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 16 Jul 2017 13:07:30 +0000 (15:07 +0200)
See #2331

wcfsetup/install/files/lib/data/package/installation/plugin/PackageInstallationPluginAction.class.php
wcfsetup/install/files/lib/system/devtools/pip/DevtoolsPip.class.php

index 7da39513a35d59d1c79c0b8656a84e8191661747..02f81a82bba66ffd8d2bc0d5106035080712a703 100644 (file)
@@ -91,9 +91,10 @@ class PackageInstallationPluginAction extends AbstractDatabaseObjectAction {
        public function invoke() {
                $dispatcher = new DevtoolsPackageInstallationDispatcher($this->project);
                /** @var IIdempotentPackageInstallationPlugin $pip */
-               $pip = new $this->packageInstallationPlugin->className($dispatcher, [
-                       'value' => $this->devtoolsPip->getInstructionValue($this->project, $this->parameters['target'])
-               ]);
+               $pip = new $this->packageInstallationPlugin->className(
+                       $dispatcher,
+                       $this->devtoolsPip->getInstructions($this->project, $this->parameters['target'])
+               );
                
                $start = microtime(true);
                
index d7215d444c80c852ef1cfea66bc16cd6d2966de1..90b335490c71856ac2e086277ab07b741fb264ce 100644 (file)
@@ -174,18 +174,20 @@ class DevtoolsPip extends DatabaseObjectDecorator {
        }
        
        /**
-        * Computes and prepares the instruction value for the provided target file.
+        * Computes and prepares the instructions for the provided target file.
         * 
         * @param       DevtoolsProject         $project
         * @param       string                  $target
-        * @return      string
+        * @return      string[]
         */
-       public function getInstructionValue(DevtoolsProject $project, $target) {
+       public function getInstructions(DevtoolsProject $project, $target) {
                $defaultFilename = $this->getDefaultFilename();
                $pluginName = $this->getDecoratedObject()->pluginName;
                $tar = $project->getPackageArchive()->getTar();
                $tar->reset();
                
+               $instructions = [];
+               
                if ($project->isCore()) {
                        switch ($pluginName) {
                                case 'acpTemplate':
@@ -238,19 +240,25 @@ class DevtoolsPip extends DatabaseObjectDecorator {
                                                }
                                        }
                                        
-                                       return $defaultFilename;
+                                       $instructions['value'] = $defaultFilename;
+                                       
+                                       break;
                                
                                case 'language':
                                        $filename = "wcfsetup/install/lang/{$target}";
                                        $tar->registerFile($filename, $project->path . $filename);
                                        
-                                       return $filename;
+                                       $instructions['value'] = $filename;
+                                       
+                                       break;
                                        
                                default:
                                        $filename = "com.woltlab.wcf/{$target}";
                                        $tar->registerFile($filename, $project->path . $filename);
                                        
-                                       return $filename;
+                                       $instructions['value'] = $filename;
+                                       
+                                       break;
                        }
                }
                else {
@@ -266,6 +274,11 @@ class DevtoolsPip extends DatabaseObjectDecorator {
                                        }
                                        else {
                                                $path = 'files/';
+                                               if (preg_match('~^files_(?<application>.*)\.tar$~', $target, $match)) {
+                                                       $path = "files_{$match['application']}/";
+                                                       
+                                                       $instructions['attributes'] = ['application' => $match['application']];
+                                               }
                                                
                                                $directory = new \RecursiveDirectoryIterator($project->path . $path);
                                                $filter = new \RecursiveCallbackFilterIterator($directory, function ($current) {
@@ -292,7 +305,9 @@ class DevtoolsPip extends DatabaseObjectDecorator {
                                                }
                                        }
                                        
-                                       return $defaultFilename;
+                                       $instructions['value'] = $defaultFilename;
+                                       
+                                       break;
                                
                                default:
                                        if (strpos($defaultFilename, '*') !== false) {
@@ -304,8 +319,12 @@ class DevtoolsPip extends DatabaseObjectDecorator {
                                                $tar->registerFile($filename, $project->path . $filename);
                                        }
                                        
-                                       return $filename;
+                                       $instructions['value'] = $filename;
+                                       
+                                       break;
                        }
                }
+               
+               return $instructions;
        }
 }