From: Tim Düsterhus Date: Wed, 3 Aug 2022 13:17:40 +0000 (+0200) Subject: Remove useless array-emptiness checks in WCFSetup::logFiles() X-Git-Tag: 6.0.0_Alpha_1~1082 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=68eea2e5c7bf98ed63387d209b4daaeb285ea328;p=GitHub%2FWoltLab%2FWCF.git 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. --- 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'); }