Remove useless array-emptiness checks in WCFSetup::logFiles()
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 3 Aug 2022 13:17:40 +0000 (15:17 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 3 Aug 2022 13:17:40 +0000 (15:17 +0200)
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.

wcfsetup/install/files/lib/system/WCFSetup.class.php

index 877dd42bfbebf89b3286ac4df983646e9ce37730..35001f4bdc064077e7b30ac554ff3fdb096fe957 100644 (file)
@@ -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');
     }