From 68eea2e5c7bf98ed63387d209b4daaeb285ea328 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Wed, 3 Aug 2022 15:17:40 +0200 Subject: [PATCH] Remove useless array-emptiness checks in WCFSetup::logFiles() a) It is impossible for theses arrays to be empty, unless the installation is seriously broken. b) Even if they were empty, it would not cause issues, as the foreach loop simply won't be entered. --- .../files/lib/system/WCFSetup.class.php | 52 ++++++++----------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/wcfsetup/install/files/lib/system/WCFSetup.class.php b/wcfsetup/install/files/lib/system/WCFSetup.class.php index 877dd42bfb..35001f4bdc 100644 --- a/wcfsetup/install/files/lib/system/WCFSetup.class.php +++ b/wcfsetup/install/files/lib/system/WCFSetup.class.php @@ -937,39 +937,33 @@ final class WCFSetup extends WCF } } - // save acp template log - if (!empty($acpTemplateInserts)) { - $sql = "INSERT INTO wcf1_acp_template - (packageID, templateName, application) - VALUES (?, ?, ?)"; - $statement = self::getDB()->prepareStatement($sql); - - self::getDB()->beginTransaction(); - foreach ($acpTemplateInserts as $acpTemplate) { - $statement->execute([1, $acpTemplate, 'wcf']); - } - self::getDB()->commitTransaction(); + $sql = "INSERT INTO wcf1_acp_template + (packageID, templateName, application) + VALUES (?, ?, ?)"; + $statement = self::getDB()->prepareStatement($sql); + + self::getDB()->beginTransaction(); + foreach ($acpTemplateInserts as $acpTemplate) { + $statement->execute([1, $acpTemplate, 'wcf']); } + self::getDB()->commitTransaction(); - // save file log - if (!empty($fileInserts)) { - $sql = "INSERT INTO wcf1_package_installation_file_log - (packageID, filename, application, sha256, lastUpdated) - VALUES (?, ?, ?, ?, ?)"; - $statement = self::getDB()->prepareStatement($sql); + $sql = "INSERT INTO wcf1_package_installation_file_log + (packageID, filename, application, sha256, lastUpdated) + VALUES (?, ?, ?, ?, ?)"; + $statement = self::getDB()->prepareStatement($sql); - self::getDB()->beginTransaction(); - foreach ($fileInserts as $file) { - $statement->execute([ - 1, - $file, - 'wcf', - \hash_file('sha256', \WCF_DIR . $file, true), - \TIME_NOW, - ]); - } - self::getDB()->commitTransaction(); + self::getDB()->beginTransaction(); + foreach ($fileInserts as $file) { + $statement->execute([ + 1, + $file, + 'wcf', + \hash_file('sha256', \WCF_DIR . $file, true), + \TIME_NOW, + ]); } + self::getDB()->commitTransaction(); return $this->gotoNextStep('installLanguage'); } -- 2.20.1