Installation now properly handles nested packages
authorAlexander Ebert <ebert@woltlab.com>
Wed, 5 Oct 2011 13:17:20 +0000 (15:17 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 5 Oct 2011 13:17:20 +0000 (15:17 +0200)
Fixes #190

wcfsetup/install/files/acp/templates/packageInstallationStepPrepare.tpl
wcfsetup/install/files/lib/acp/action/InstallPackageAction.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php

index 17088fcd0db69cd7d29c6ca01fc989942c68bfa7..d2a32ddddf0b8c1bd5c8efe94786e26d7e6904ba 100644 (file)
@@ -2,7 +2,7 @@
        <header class="mainHeading">
                <img src="{@RELATIVE_WCF_DIR}icon/installation1.svg" alt="" />
                <hgroup>
-                       <h1>Paket &raquo;{$queue->packageName}&laquo; wird installiert &hellip;</h1>
+                       <h1>Paket &raquo;{$packageName}&laquo; wird installiert &hellip;</h1>
                        <h2>Aktueller Schritt: <span id="packageInstallationAction">{lang}wcf.package.installation.step.prepare{/lang}</span></h2>
                        <p><progress id="packageInstallationProgress" value="0" max="100" style="width: 200px;">0%</progress></p>
                </hgroup>
@@ -11,4 +11,4 @@
        <div id="packageInstallationInnerContentContainer" class="" style="display: none;">
                <div id="packageInstallationInnerContent" class=""></div>
        </div>
-</div>
\ No newline at end of file
+</div>
index 54960a83d14d5f47428abe123c39db8b2cb87b9e..ac59afcc65c2c9ff6ea7823ef918d48d419f22af 100755 (executable)
@@ -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
                );
        }
        
index cec793fe6a071bd9003f33a19fb3c867aad9085a..2a0a0ccb2b4f41cf9c46383f8a7384662c3a37f3 100644 (file)
@@ -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/', '*');
        }
        
        /**
index 1bde19551222a869c89830149b930ab4142fc371..2690fe61c01f24fd296cdb001c6e695f57f232ad 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 namespace wcf\system\package;
 use wcf\data\package\installation\queue\PackageInstallationQueue;
+use wcf\data\package\installation\queue\PackageInstallationQueueEditor;
 use wcf\system\WCF;
+use wcf\util\FileUtil;
 use wcf\util\StringUtil;
 
 /**
@@ -87,12 +89,10 @@ class PackageInstallationNodeBuilder {
        public function getNextNode($parentNode = '') {
                $sql = "SELECT  node
                        FROM    wcf".WCF_N."_package_installation_node
-                       WHERE   queueID = ?
-                               AND processNo = ?
+                       WHERE   processNo = ?
                                AND parentNode = ?";
                $statement = WCF::getDB()->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'];
+       }
 }