From 792278848e22a9c1bbe710176ed9f54f67f0fa7d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 15 Nov 2022 11:07:26 +0100 Subject: [PATCH] Further streamline the logic in PackageArchive::getExistingRequirements() --- .../system/package/PackageArchive.class.php | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php index 4e79ab3910..71bda79e32 100644 --- a/wcfsetup/install/files/lib/system/package/PackageArchive.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageArchive.class.php @@ -706,26 +706,21 @@ class PackageArchive */ public function getExistingRequirements() { - // build sql - $packageNames = []; - foreach ($this->requirements as $requirement) { - $packageNames[] = $requirement['name']; - } + $packageNames = \array_column($this->requirements, 'name'); + \assert($packageNames !== []); // check whether the required packages do already exist - $existingPackages = []; - if (!empty($packageNames)) { - $conditions = new PreparedStatementConditionBuilder(); - $conditions->add("package IN (?)", [$packageNames]); + $conditions = new PreparedStatementConditionBuilder(); + $conditions->add("package IN (?)", [$packageNames]); - $sql = "SELECT * - FROM wcf1_package - {$conditions}"; - $statement = WCF::getDB()->prepare($sql); - $statement->execute($conditions->getParameters()); - while ($row = $statement->fetchArray()) { - $existingPackages[$row['package']] = $row; - } + $sql = "SELECT * + FROM wcf1_package + {$conditions}"; + $statement = WCF::getDB()->prepare($sql); + $statement->execute($conditions->getParameters()); + $existingPackages = []; + while ($row = $statement->fetchArray()) { + $existingPackages[$row['package']] = $row; } return $existingPackages; -- 2.20.1