From 4fc606adfba733adb12f9118a39a095a97502097 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 6 Nov 2023 14:02:19 +0100 Subject: [PATCH] Fix the handling of unknown packages --- .../lib/system/package/PackageUpdateDispatcher.class.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php index 894f6f182c..5d8b6f37f7 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php @@ -848,6 +848,10 @@ final class PackageUpdateDispatcher extends SingletonFactory $version = $this->getNewestPackageVersion($package); } + if ($version === null) { + throw new SystemException("Cannot find the package '" . $package . "'"); + } + // get versions $conditions = new PreparedStatementConditionBuilder(); $conditions->add('pu.package = ?', [$package]); @@ -867,7 +871,7 @@ final class PackageUpdateDispatcher extends SingletonFactory $versions = $statement->fetchAll(\PDO::FETCH_ASSOC); if (empty($versions)) { - throw new SystemException("Cannot find package '" . $package . "' in version '" . $version . "'"); + throw new SystemException("Cannot find the package '" . $package . "' in version '" . $version . "'"); } return $versions; @@ -876,7 +880,7 @@ final class PackageUpdateDispatcher extends SingletonFactory /** * Returns the newest available version of a package. */ - public function getNewestPackageVersion(string $package): string + public function getNewestPackageVersion(string $package): ?string { // get all versions $versions = []; -- 2.20.1