From 3f6d1923dca8d9cac249b4b0c4a8b6f59bdfb09a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 18 Nov 2022 12:19:46 +0100 Subject: [PATCH] Improve readability of `$instructions` fetch in PackageInstallationNodeBuilder::buildPluginNodes() --- .../PackageInstallationNodeBuilder.class.php | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php index 7f1649b4c3..66a271ade1 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php @@ -616,13 +616,22 @@ class PackageInstallationNodeBuilder $pluginNodes = []; $this->emptyNode = true; - $instructions = match ($this->installation->getAction()) { - 'install' => $this->installation->getArchive()->getInstallInstructions(), - 'update' => $this->installation->getArchive()->getUpdateInstructionsFor( - self::$pendingPackages[$this->installation->getPackage()->package] - ?? $this->installation->getPackage()->packageVersion - ) ?? [], - }; + + switch ($this->installation->getAction()) { + case 'install': + $instructions = $this->installation->getArchive()->getInstallInstructions(); + + break; + case 'update': + $package = $this->installation->getPackage(); + $currentPackageVersion = self::$pendingPackages[$package->package] ?? $package->packageVersion; + $instructions = $this->installation->getArchive()->getUpdateInstructionsFor($currentPackageVersion) ?? []; + + break; + default: + throw new \LogicException('Unreachable'); + } + $count = \count($instructions); if ($count === 0) { -- 2.20.1