From b378243093b3fcf8c061349695e2b63fba994fd0 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 20 May 2013 00:50:18 +0200 Subject: [PATCH] Fixed update --- com.woltlab.wcf/update_post_b1.sql | 2 +- .../install/files/acp/update_4.0.0_b1.php | 19 ++++++++ .../PackageInstallationDispatcher.class.php | 43 ++++++++++++++++++- .../PackageInstallationNodeBuilder.class.php | 12 +++++- 4 files changed, 73 insertions(+), 3 deletions(-) diff --git a/com.woltlab.wcf/update_post_b1.sql b/com.woltlab.wcf/update_post_b1.sql index ef35bd8a0e..23912e8638 100644 --- a/com.woltlab.wcf/update_post_b1.sql +++ b/com.woltlab.wcf/update_post_b1.sql @@ -2,4 +2,4 @@ CREATE UNIQUE INDEX applicationTemplate ON wcf1_acp_template (application, templ CREATE UNIQUE INDEX applicationFile ON wcf1_package_installation_file_log (application, filename); -CREATE UNIQUE INDEX applicationTemplate ON wcf1_template (application, templateGroupID templateName); +CREATE UNIQUE INDEX applicationTemplate ON wcf1_template (application, templateGroupID, templateName); diff --git a/wcfsetup/install/files/acp/update_4.0.0_b1.php b/wcfsetup/install/files/acp/update_4.0.0_b1.php index a7b04f6d63..7b3bd26038 100644 --- a/wcfsetup/install/files/acp/update_4.0.0_b1.php +++ b/wcfsetup/install/files/acp/update_4.0.0_b1.php @@ -46,3 +46,22 @@ foreach ($packageList as $package) { $package->packageID )); } + +// assign all other files/templates to WCF +$sql = "UPDATE wcf".WCF_N."_acp_template + SET application = ? + WHERE application = ?"; +$statement = WCF::getDB()->prepareStatement($sql); +$statement->execute(array('wcf', '')); + +$sql = "UPDATE wcf".WCF_N."_package_installation_file_log + SET application = ? + WHERE application = ?"; +$statement = WCF::getDB()->prepareStatement($sql); +$statement->execute(array('wcf', '')); + +$sql = "UPDATE wcf".WCF_N."_template + SET application = ? + WHERE application = ?"; +$statement = WCF::getDB()->prepareStatement($sql); +$statement->execute(array('wcf', '')); diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index 5054260911..8dc5c06f2d 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -263,7 +263,48 @@ class PackageInstallationDispatcher { } unset($nodeData['requirements']); - if (!$this->queue->packageID) { + // update package + if ($this->queue->packageID) { + $packageEditor = new PackageEditor(new Package($this->queue->packageID)); + $packageEditor->update($nodeData); + + // update excluded packages + if (count($this->getArchive()->getExcludedPackages()) > 0) { + $sql = "INSERT IGNORE INTO wcf".WCF_N."_package_exclusion + (packageID, excludedPackage, excludedPackageVersion) + VALUES (?, ?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + + foreach ($this->getArchive()->getExcludedPackages() as $excludedPackage) { + $statement->execute(array($this->queue->packageID, $excludedPackage['name'], (!empty($excludedPackage['version']) ? $excludedPackage['version'] : ''))); + } + } + + // if package is plugin to com.woltlab.wcf it must not have any other requirement + $requirements = $this->getArchive()->getRequirements(); + + // insert requirements and dependencies + $requirements = $this->getArchive()->getAllExistingRequirements(); + if (!empty($requirements)) { + $sql = "INSERT IGNORE INTO wcf".WCF_N."_package_requirement + (packageID, requirement) + VALUES (?, ?)"; + $statement = WCF::getDB()->prepareStatement($sql); + + foreach ($requirements as $identifier => $possibleRequirements) { + if (count($possibleRequirements) == 1) { + $requirement = array_shift($possibleRequirements); + } + else { + $requirement = $possibleRequirements[$this->selectedRequirements[$identifier]]; + } + + $statement->execute(array($this->queue->packageID, $requirement['packageID'])); + } + } + + } + else { // create package entry $package = PackageEditor::create($nodeData); diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php index 3363ec3a82..66ec2b3557 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php @@ -437,15 +437,25 @@ class PackageInstallationNodeBuilder { $archive = new PackageArchive($fileName); $archive->openArchive(); + // get package id + $sql = "SELECT packageID + FROM wcf".WCF_N."_package + WHERE package = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array($archive->getPackageInfo('name'))); + $row = $statement->fetchArray(); + $packageID = ($row === false) ? null : $row['packageID']; + // create new queue $queue = PackageInstallationQueueEditor::create(array( 'parentQueueID' => $queue->queueID, 'processNo' => $queue->processNo, 'userID' => WCF::getUser()->userID, 'package' => $archive->getPackageInfo('name'), + 'packageID' => $packageID, 'packageName' => $archive->getLocalizedPackageInfo('packageName'), 'archive' => $fileName, - 'action' => $queue->action + 'action' => ($packageID ? 'update' : 'install') )); // spawn nodes -- 2.20.1