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

eliashaeussler / typo3-warming / 17710663153

14 Sep 2025 11:40AM UTC coverage: 90.136% (-2.6%) from 92.759%
17710663153

Pull #959

github

eliashaeussler
[FEATURE] Run cache warmup after DataHandler cache clear
Pull Request #959: [FEATURE] Run cache warmup after DataHandler cache clear

21 of 83 new or added lines in 3 files covered. (25.3%)

1718 of 1906 relevant lines covered (90.14%)

13.09 hits per line

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

54.17
/Classes/Queue/CacheWarmupQueue.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the TYPO3 CMS extension "warming".
7
 *
8
 * Copyright (C) 2021-2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 2 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\Typo3Warming\Queue;
25

26
use EliasHaeussler\CacheWarmup;
27
use EliasHaeussler\Typo3SitemapLocator;
28
use EliasHaeussler\Typo3Warming\Result;
29
use EliasHaeussler\Typo3Warming\Service;
30
use EliasHaeussler\Typo3Warming\ValueObject;
31
use GuzzleHttp\Exception;
32
use TYPO3\CMS\Core;
33

34
/**
35
 * CacheWarmupQueue
36
 *
37
 * @author Elias Häußler <elias@haeussler.dev>
38
 * @license GPL-2.0-or-later
39
 * @internal
40
 */
41
final class CacheWarmupQueue implements Core\SingletonInterface
42
{
43
    /**
44
     * @var list<ValueObject\Request\SiteWarmupRequest>
45
     */
46
    private array $siteWarmupRequests = [];
47

48
    /**
49
     * @var list<ValueObject\Request\PageWarmupRequest>
50
     */
51
    private array $pageWarmupRequests = [];
52

53
    public function __construct(
38✔
54
        private readonly Service\CacheWarmupService $cacheWarmupService,
55
    ) {}
38✔
56

NEW
57
    public function enqueue(
×
58
        ValueObject\Request\SiteWarmupRequest|ValueObject\Request\PageWarmupRequest $cacheWarmupRequest,
59
    ): self {
NEW
60
        if ($cacheWarmupRequest instanceof ValueObject\Request\SiteWarmupRequest) {
×
NEW
61
            $this->siteWarmupRequests[] = $cacheWarmupRequest;
×
62
        }
63

NEW
64
        if ($cacheWarmupRequest instanceof ValueObject\Request\PageWarmupRequest) {
×
NEW
65
            $this->pageWarmupRequests[] = $cacheWarmupRequest;
×
66
        }
67

NEW
68
        return $this;
×
69
    }
70

71
    /**
72
     * @throws CacheWarmup\Exception\Exception
73
     * @throws Typo3SitemapLocator\Exception\BaseUrlIsNotSupported
74
     * @throws Typo3SitemapLocator\Exception\SitemapIsMissing
75
     * @throws Exception\GuzzleException
76
     */
77
    public function process(): ?Result\CacheWarmupResult
38✔
78
    {
79
        // Early return if no cache warmup requests were enqueued
80
        if ($this->isEmpty()) {
38✔
81
            return null;
38✔
82
        }
83

84
        try {
NEW
85
            return $this->cacheWarmupService->warmup($this->siteWarmupRequests, $this->pageWarmupRequests);
×
86
        } finally {
NEW
87
            $this->clear();
×
88
        }
89
    }
90

91
    public function wrapInWarmupRequest(): ValueObject\Request\WarmupRequest
38✔
92
    {
93
        return new ValueObject\Request\WarmupRequest(
38✔
94
            /* @phpstan-ignore argument.type (until return type annotation is fixed in core) */
95
            Core\Utility\StringUtility::getUniqueId(),
38✔
96
            $this->siteWarmupRequests,
38✔
97
            $this->pageWarmupRequests,
38✔
98
        );
38✔
99
    }
100

101
    /**
102
     * @phpstan-assert-if-true null $this->process()
103
     */
104
    public function isEmpty(): bool
38✔
105
    {
106
        return $this->pageWarmupRequests === [] && $this->siteWarmupRequests === [];
38✔
107
    }
108

NEW
109
    private function clear(): void
×
110
    {
NEW
111
        $this->siteWarmupRequests = [];
×
NEW
112
        $this->pageWarmupRequests = [];
×
113
    }
114
}
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