Commit 9047fa29 authored by Fabian Galinski's avatar Fabian Galinski 😾
Browse files

Update BackendService.php

parent ed3afb88
......@@ -390,7 +390,6 @@ class BackendService {
*/
public static function writeCsvFromQueue(array $filters = []) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var MailRepository $mailRepository */
$mailRepository = $objectManager->get(MailRepository::class);
$pageUid = (int) GeneralUtility::_GP('id');
......@@ -403,14 +402,12 @@ class BackendService {
$totalRows = $doctrineQuery->execute()->fetchColumn(0);
$doctrineQuery->select('*');
$batchSize = self::CSV_EXPORT_BATCH_SIZE;
$offset = 0;
$first = TRUE;
$handle = fopen('php://output', 'w+');
while ($offset + $batchSize <= $totalRows) {
while ($offset + self::CSV_EXPORT_BATCH_SIZE <= $totalRows) {
$doctrineQuery->setFirstResult($offset);
$doctrineQuery->setMaxResults($batchSize);
$doctrineQuery->setMaxResults(self::CSV_EXPORT_BATCH_SIZE);
$rows = $doctrineQuery->execute();
while ($mail = $rows->fetch()) {
if ($first) { // Write column headers before the first row
......@@ -426,6 +423,7 @@ class BackendService {
$row[] = '"' . ($label ?: $field) . '"';
}
}
fwrite(
$handle, trim(
preg_replace(
......@@ -436,6 +434,7 @@ class BackendService {
)
);
}
$row = [];
foreach ($mail as $field => $value) {
if (!\in_array($field, $ignoreFields, TRUE)) {
......@@ -446,6 +445,7 @@ class BackendService {
}
}
}
fwrite(
$handle, trim(
preg_replace(
......@@ -456,7 +456,8 @@ class BackendService {
)
);
}
$offset += $batchSize;
$offset += self::CSV_EXPORT_BATCH_SIZE;
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment