From: Tim Düsterhus Date: Tue, 15 Nov 2022 10:07:26 +0000 (+0100) Subject: Further streamline the logic in PackageArchive::getExistingRequirements() X-Git-Tag: 6.0.0_Alpha_1~719^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=792278848e22a9c1bbe710176ed9f54f67f0fa7d;p=GitHub%2FWoltLab%2FWCF.git Further streamline the logic in PackageArchive::getExistingRequirements() --- 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;