• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tomasnorre / crawler / 17624430237

10 Sep 2025 07:17PM UTC coverage: 67.575% (-1.2%) from 68.768%
17624430237

Pull #1183

github

web-flow
Merge 8c98d5af1 into 96cae4d2b
Pull Request #1183: [TASK] Refactor ProcessCleanupHook, extract logic to ProcessManager and ProcessCleaner classes

4 of 55 new or added lines in 6 files covered. (7.27%)

17 existing lines in 1 file now uncovered.

1859 of 2751 relevant lines covered (67.58%)

3.18 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Classes/Process/Cleaner/OrphanProcessCleaner.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace AOE\Crawler\Process\Cleaner;
6

7
/*
8
 * (c) 2025 Tomas Norre Mikkelsen <tomasnorre@gmail.com>
9
 *
10
 * This file is part of the TYPO3 Crawler Extension.
11
 *
12
 * It is free software; you can redistribute it and/or modify it under
13
 * the terms of the GNU General Public License, either version 2
14
 * of the License, or any later version.
15
 *
16
 * For the full copyright and license information, please read the
17
 * LICENSE.txt file that was distributed with this source code.
18
 *
19
 * The TYPO3 project - inspiring people to share!
20
 */
21

22
use AOE\Crawler\Domain\Repository\ProcessRepository;
23
use AOE\Crawler\Domain\Repository\QueueRepository;
24
use AOE\Crawler\Process\ProcessManagerInterface;
25
use TYPO3\CMS\Core\Utility\GeneralUtility;
26

27
class OrphanProcessCleaner
28
{
29
    public function __construct(
30
        private readonly ProcessRepository $processRepository,
31
        private readonly QueueRepository $queueRepository,
32
        private readonly ProcessManagerInterface $processManager
33
    ) {
NEW
34
    }
×
35

36
    public function clean(): void
37
    {
NEW
38
        $results = $this->processRepository->getActiveOrphanProcesses();
×
39

NEW
40
        foreach ($results as $result) {
×
NEW
41
            $systemProcessId = (int) $result['system_process_id'];
×
NEW
42
            $processId = $result['process_id'];
×
43

NEW
44
            if ($systemProcessId <= 1) {
×
NEW
45
                continue;
×
46
            }
47

NEW
48
            $dispatcherProcesses = $this->processManager->findDispatcherProcesses();
×
NEW
49
            if (empty($dispatcherProcesses)) {
×
NEW
50
                $this->remove($processId);
×
NEW
51
                return;
×
52
            }
53

NEW
54
            $exists = false;
×
NEW
55
            foreach ($dispatcherProcesses as $process) {
×
NEW
56
                $parts = GeneralUtility::trimExplode(' ', $process, true);
×
NEW
57
                if ($systemProcessId === (int) ($parts[1] ?? 0)) {
×
NEW
58
                    $exists = true;
×
NEW
59
                    break;
×
60
                }
61
            }
62

NEW
63
            if (!$exists) {
×
NEW
64
                $this->remove($processId);
×
65
            }
66
        }
67
    }
68

69
    private function remove(string $processId): void
70
    {
NEW
71
        $this->processRepository->removeByProcessId($processId);
×
NEW
72
        $this->queueRepository->unsetQueueProcessId($processId);
×
73
    }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc