Skip to content

Commit 838548c

Browse files
authored
Merge pull request #439 from plan2net/bugfix/backend-iterator
[BUGFIX] Fix boostAction to properly handle Generator iterables
2 parents fe11a4f + 469d945 commit 838548c

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

Classes/Controller/BackendController.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace SFC\Staticfilecache\Controller;
66

7+
use Doctrine\DBAL\Exception;
78
use Psr\Log\LoggerAwareInterface;
89
use Psr\Log\LoggerAwareTrait;
910
use SFC\Staticfilecache\Cache\UriFrontend;
@@ -50,26 +51,42 @@ public function listAction(string $filter = ''): ResponseInterface
5051
->renderResponse('Backend/List');
5152
}
5253

54+
/**
55+
* @throws Exception
56+
*/
5357
public function boostAction(bool $run = false): ResponseInterface
5458
{
5559
$queueRepository = GeneralUtility::makeInstance(QueueRepository::class);
5660
if ($run) {
5761
$items = $queueRepository->findOpen(10);
62+
$processedCount = 0;
5863

5964
try {
6065
foreach ($items as $item) {
6166
$this->queueService->runSingleRequest($item);
67+
$processedCount++;
6268
}
63-
} catch (\Exception $exception) {
69+
} catch (\Throwable $exception) {
6470
$this->addFlashMessage('Error in run: ' . $exception->getMessage(), 'Runner', ContextualFeedbackSeverity::ERROR, true);
6571
}
6672

67-
$this->addFlashMessage('Run ' . \count($items) . ' entries', 'Runner', ContextualFeedbackSeverity::OK, true);
73+
$this->addFlashMessage('Run ' . $processedCount . ' entries', 'Runner', ContextualFeedbackSeverity::OK, true);
74+
}
75+
76+
$openCount = 0;
77+
foreach ($queueRepository->findOpen(99999999) as $ignored) {
78+
$openCount++;
6879
}
80+
81+
$oldCount = 0;
82+
foreach ($queueRepository->findOldUids() as $ignored1) {
83+
$oldCount++;
84+
}
85+
6986
$viewVariables = [
7087
'enable' => (bool) $this->configurationService->get('boostMode'),
71-
'open' => \count(iterator_to_array($queueRepository->findOpen(99999999))),
72-
'old' => \count(iterator_to_array($queueRepository->findOldUids())),
88+
'open' => $openCount,
89+
'old' => $oldCount,
7390
];
7491

7592
return $this->createModuleTemplate()

0 commit comments

Comments
 (0)