From: Marcel Werk Date: Tue, 12 Apr 2022 12:00:40 +0000 (+0200) Subject: Use limit/offset for fetching the attachments X-Git-Tag: 5.5.0_Beta_1~5^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=286d5ba990b2e7a3ff9c9957c4fa6a2a6724425f;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.exporter.git Use limit/offset for fetching the attachments --- diff --git a/files/lib/system/exporter/WBB3xExporter.class.php b/files/lib/system/exporter/WBB3xExporter.class.php index 8ec2744..a11678e 100644 --- a/files/lib/system/exporter/WBB3xExporter.class.php +++ b/files/lib/system/exporter/WBB3xExporter.class.php @@ -3145,13 +3145,13 @@ class WBB3xExporter extends AbstractExporter } if (\substr($this->getPackageVersion('com.woltlab.wcf'), 0, 3) == '1.1') { - $sql = "SELECT MAX(attachmentID) + $sql = "SELECT COUNT(*) FROM wcf" . $this->dbNo . "_attachment WHERE packageID = ? AND containerID > ? AND containerType = ?"; } else { - $sql = "SELECT MAX(attachmentID) + $sql = "SELECT COUNT(*) FROM wcf" . $this->dbNo . "_attachment WHERE packageID = ? AND messageID > ? @@ -3160,7 +3160,7 @@ class WBB3xExporter extends AbstractExporter $statement = $this->database->prepareStatement($sql); $statement->execute([$packageID, 0, $type]); - return $statement->fetchSingleColumn() ?: 0; + return $statement->fetchSingleColumn(); } /** @@ -3184,7 +3184,6 @@ class WBB3xExporter extends AbstractExporter WHERE packageID = ? AND containerID > ? AND containerType = ? - AND attachmentID BETWEEN ? AND ? ORDER BY attachmentID"; } else { $sql = "SELECT * @@ -3192,12 +3191,11 @@ class WBB3xExporter extends AbstractExporter WHERE packageID = ? AND messageID > ? AND messageType = ? - AND attachmentID BETWEEN ? AND ? ORDER BY attachmentID"; } - $statement = $this->database->prepareStatement($sql, $limit); - $statement->execute([$packageID, 0, $type, $offset + 1, $offset + $limit]); + $statement = $this->database->prepareStatement($sql, $limit, $offset); + $statement->execute([$packageID, 0, $type]); while ($row = $statement->fetchArray()) { $fileLocation = $this->fileSystemPath . 'attachments/attachment-' . $row['attachmentID'];