Support database PIP in devtools sync function
authorMatthias Schmidt <gravatronics@live.com>
Sun, 14 Mar 2021 08:07:37 +0000 (09:07 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 14 Mar 2021 08:07:37 +0000 (09:07 +0100)
ts/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Devtools/Project/Sync.js
wcfsetup/install/files/lib/data/package/installation/plugin/PackageInstallationPluginAction.class.php
wcfsetup/install/files/lib/system/devtools/pip/DevtoolsPip.class.php

index 62fdbb7570fdd9385a0aad3d67c4b13f53a0b431..667d207b8830a305ba1d8bf6bc08ada614d36e45 100644 (file)
@@ -15,6 +15,7 @@ type PendingPip = [string, string];
 
 interface AjaxResponse {
   returnValues: {
+    invokeAgain: boolean;
     pluginName: string;
     target: string;
     timeElapsed: string;
@@ -203,7 +204,11 @@ class AcpUiDevtoolsProjectSync {
     this.buttons.get(identifier)!.disabled = false;
     this.buttonStatus.get(identifier)!.innerHTML = data.returnValues.timeElapsed;
 
-    this.syncNext();
+    if (data.returnValues.invokeAgain) {
+      this.sync(data.returnValues.pluginName, data.returnValues.target);
+    } else {
+      this.syncNext();
+    }
   }
 
   _ajaxFailure(
index a08f8613a857a7161f052e2411c95cf75006b8b7..b550ad8cc20c7bb100773956f1db4129472f99cc 100644 (file)
@@ -139,7 +139,12 @@ define(["require", "exports", "tslib", "../../../../Ajax", "../../../../Language
             const identifier = this.getButtonIdentifier(data.returnValues.pluginName, data.returnValues.target);
             this.buttons.get(identifier).disabled = false;
             this.buttonStatus.get(identifier).innerHTML = data.returnValues.timeElapsed;
-            this.syncNext();
+            if (data.returnValues.invokeAgain) {
+                this.sync(data.returnValues.pluginName, data.returnValues.target);
+            }
+            else {
+                this.syncNext();
+            }
         }
         _ajaxFailure(data, responseText, xhr, requestData) {
             const identifier = this.getButtonIdentifier(requestData.parameters.pluginName, requestData.parameters.target);
index 61c32a53c87bc5ef6e4fb5b54db1136ecb69d386..e3d0286c5c55cf07abedeea0a775c98221686013 100644 (file)
@@ -107,10 +107,15 @@ class PackageInstallationPluginAction extends AbstractDatabaseObjectAction
 
         $start = \microtime(true);
 
+        $invokeAgain = false;
         try {
             $pip->update();
         } catch (SplitNodeException $e) {
-            throw new \RuntimeException("PIP '{$this->packageInstallationPlugin->pluginName}' is not allowed to throw a 'SplitNodeException'.");
+            if ($this->parameters['pluginName'] !== 'database') {
+                throw new \RuntimeException("PIP '{$this->packageInstallationPlugin->pluginName}' is not allowed to throw a 'SplitNodeException'.");
+            }
+
+            $invokeAgain = true;
         }
 
         SearchIndexManager::getInstance()->createSearchIndices();
@@ -143,6 +148,7 @@ class PackageInstallationPluginAction extends AbstractDatabaseObjectAction
         }
 
         return [
+            'invokeAgain' => $invokeAgain,
             'pluginName' => $this->packageInstallationPlugin->pluginName,
             'target' => $this->parameters['target'],
             'timeElapsed' => WCF::getLanguage()->getDynamicVariable(
index fa3f70208ba820a7457b4afb61ef224740328064..b3d0fced91bafece86dafff340b38e3ba121554c 100644 (file)
@@ -6,6 +6,7 @@ use wcf\data\DatabaseObjectDecorator;
 use wcf\data\devtools\project\DevtoolsProject;
 use wcf\data\package\installation\plugin\PackageInstallationPlugin;
 use wcf\system\application\ApplicationHandler;
+use wcf\system\package\plugin\DatabasePackageInstallationPlugin;
 use wcf\system\package\plugin\IPackageInstallationPlugin;
 use wcf\system\WCF;
 use wcf\util\FileUtil;
@@ -200,6 +201,16 @@ class DevtoolsPip extends DatabaseObjectDecorator
                     // these pips are satisfied by definition
                     return [$defaultFilename];
 
+                case 'database':
+                    foreach (\glob("{$path}wcfsetup/install/files/{$defaultFilename}") as $file) {
+                        $targets[] = \basename($file);
+                    }
+
+                    // `glob()` returns files in an arbitrary order
+                    \sort($targets, \SORT_NATURAL);
+
+                    return $targets;
+
                 case 'language':
                     foreach (\glob($path . 'wcfsetup/install/lang/*.xml') as $file) {
                         $targets[] = \basename($file);
@@ -330,6 +341,13 @@ class DevtoolsPip extends DatabaseObjectDecorator
 
                     break;
 
+                case 'database':
+                    $instructions['value'] = DatabasePackageInstallationPlugin::SCRIPT_DIR . $target;
+
+                    $tar->registerFile($instructions['value'], $project->path . 'wcfsetup/install/files/' . $target);
+
+                    break;
+
                 case 'language':
                     $tar->registerFile($target, $project->path . 'wcfsetup/install/lang/' . $target);