From cfedc21637518005a76280774ba0fe039b28e78f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 5 Oct 2011 15:17:20 +0200 Subject: [PATCH] Installation now properly handles nested packages Fixes #190 --- .../packageInstallationStepPrepare.tpl | 4 +- .../acp/action/InstallPackageAction.class.php | 27 +++++------ .../PackageInstallationDispatcher.class.php | 45 ++++--------------- .../PackageInstallationNodeBuilder.class.php | 42 ++++++++++------- 4 files changed, 48 insertions(+), 70 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/packageInstallationStepPrepare.tpl b/wcfsetup/install/files/acp/templates/packageInstallationStepPrepare.tpl index 17088fcd0d..d2a32ddddf 100644 --- a/wcfsetup/install/files/acp/templates/packageInstallationStepPrepare.tpl +++ b/wcfsetup/install/files/acp/templates/packageInstallationStepPrepare.tpl @@ -2,7 +2,7 @@
-

Paket »{$queue->packageName}« wird installiert …

+

Paket »{$packageName}« wird installiert …

Aktueller Schritt: {lang}wcf.package.installation.step.prepare{/lang}

0%

@@ -11,4 +11,4 @@ - \ No newline at end of file + diff --git a/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php b/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php index 54960a83d1..ac59afcc65 100755 --- a/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php +++ b/wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php @@ -69,31 +69,23 @@ class InstallPackageAction extends AbstractDialogAction { */ protected function stepInstall() { $step = $this->installation->install($this->node); + $queueID = $this->installation->nodeBuilder->getQueueByNode($this->installation->queue->processNo, $step->getNode()); if ($step->hasDocument()) { $this->data = array( 'innerTemplate' => $step->getTemplate(), 'node' => $step->getNode(), 'progress' => $this->installation->nodeBuilder->calculateProgress($this->node), - 'step' => 'install' + 'step' => 'install', + 'queueID' => $queueID ); } else { if ($step->getNode() == '') { // perform final actions - $queueID = $this->installation->completeSetup(); - - // begin with next queue - if ($queueID) { - $this->data = array( - 'progress' => 100, - 'queueID' => $queueID, - 'step' => 'prepare' - ); - return; - } + $this->installation->completeSetup(); - // no more queues, show success + // show success $this->data = array( 'progress' => 100, 'step' => 'success' @@ -105,7 +97,8 @@ class InstallPackageAction extends AbstractDialogAction { $this->data = array( 'step' => 'install', 'node' => $step->getNode(), - 'progress' => $this->installation->nodeBuilder->calculateProgress($this->node) + 'progress' => $this->installation->nodeBuilder->calculateProgress($this->node), + 'queueID' => $queueID ); } } @@ -123,9 +116,10 @@ class InstallPackageAction extends AbstractDialogAction { // create node tree $this->installation->nodeBuilder->buildNodes(); $nextNode = $this->installation->nodeBuilder->getNextNode(); + $queueID = $this->installation->nodeBuilder->getQueueByNode($this->installation->queue->processNo, $nextNode); WCF::getTPL()->assign(array( - 'queue' => $this->queue + 'packageName' => $this->installation->queue->packageName )); $this->data = array( @@ -133,7 +127,8 @@ class InstallPackageAction extends AbstractDialogAction { 'step' => 'install', 'node' => $nextNode, 'currentAction' => WCF::getLanguage()->get('wcf.package.installation.step.installing'), - 'progress' => 0 + 'progress' => 0, + 'queueID' => $queueID ); } diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index cec793fe6a..2a0a0ccb2b 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -99,6 +99,10 @@ class PackageInstallationDispatcher { case 'pip': $step = $this->executePIP($nodeData); break; + + default: + die("Unknown node type: '".$data['nodeType']."'"); + break; } if ($step->splitNode()) { @@ -512,32 +516,6 @@ class PackageInstallationDispatcher { return $row['queueID']; } - /** - * Returns next queue within an installation process. - * - * @return integer - */ - protected function getNextQueue() { - $sql = "SELECT queueID - FROM wcf".WCF_N."_package_installation_queue - WHERE userID = ? - AND processNo = ? - AND done = 0 - ORDER BY queueID ASC"; - $statement = WCF::getDB()->prepareStatement($sql); - $statement->execute(array( - WCF::getUser()->userID, - $this->queue->processNo - )); - $row = $statement->fetchArray(); - - if (!$row) { - return 0; - } - - return $row['queueID']; - } - /** * Executes post-setup actions. */ @@ -563,18 +541,11 @@ class PackageInstallationDispatcher { )); } - // return next queue within the same process no - $queueID = $this->getNextQueue(); - - if (!$queueID) { - // clear language files once whole installation is completed - LanguageEditor::deleteLanguageFiles(); - - // reset all caches - CacheHandler::getInstance()->clear(WCF_DIR.'cache/', '*'); - } + // clear language files once whole installation is completed + LanguageEditor::deleteLanguageFiles(); - return $queueID; + // reset all caches + CacheHandler::getInstance()->clear(WCF_DIR.'cache/', '*'); } /** diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php index 1bde195512..2690fe61c0 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php @@ -1,7 +1,9 @@ prepareStatement($sql); $statement->execute(array( - $this->installation->queue->queueID, $this->installation->queue->processNo, $parentNode )); @@ -114,13 +114,11 @@ class PackageInstallationNodeBuilder { public function getNodeData($node) { $sql = "SELECT nodeType, nodeData, sequenceNo FROM wcf".WCF_N."_package_installation_node - WHERE queueID = ? - AND processNo = ? + WHERE processNo = ? AND node = ? ORDER BY sequenceNo ASC"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array( - $this->installation->queue->queueID, $this->installation->queue->processNo, $node )); @@ -140,12 +138,10 @@ class PackageInstallationNodeBuilder { public function completeNode($node) { $sql = "UPDATE wcf".WCF_N."_package_installation_node SET done = 1 - WHERE queueID = ? - AND processNo = ? + WHERE processNo = ? AND node = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array( - $this->installation->queue->queueID, $this->installation->queue->processNo, $node )); @@ -225,13 +221,11 @@ class PackageInstallationNodeBuilder { $sql = "UPDATE wcf".WCF_N."_package_installation_node SET parentNode = ? WHERE parentNode = ? - AND queueID = ? AND processNo = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array( $newNode, $node, - $this->installation->queue->queueID, $this->installation->queue->processNo )); @@ -239,13 +233,11 @@ class PackageInstallationNodeBuilder { $sql = "SELECT nodeType, nodeData, done FROM wcf".WCF_N."_package_installation_node WHERE node = ? - AND queueID = ? AND processNo = ? AND sequenceNo = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array( $node, - $this->installation->queue->queueID, $this->installation->queue->processNo, $sequenceNo )); @@ -272,7 +264,6 @@ class PackageInstallationNodeBuilder { node = ?, sequenceNo = (sequenceNo - ?) WHERE node = ? - AND queueID = ? AND processNo = ? AND sequenceNo > ?"; $statement = WCF::getDB()->prepareStatement($sql); @@ -281,7 +272,6 @@ class PackageInstallationNodeBuilder { $newNode, $sequenceNo, $node, - $this->installation->queue->queueID, $this->installation->queue->processNo, $sequenceNo )); @@ -505,4 +495,26 @@ class PackageInstallationNodeBuilder { protected function getToken() { return StringUtil::substring(StringUtil::getRandomID(), 0, 8); } + + /** + * Returns queue id based upon current node. + * + * @param integer $processNo + * @param string $node + * @return integer + */ + public function getQueueByNode($processNo, $node) { + $sql = "SELECT queueID + FROM wcf".WCF_N."_package_installation_node + WHERE processNo = ? + AND node = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array( + $processNo, + $node + )); + $row = $statement->fetchArray(); + + return $row['queueID']; + } } -- 2.20.1