• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Build has been canceled!

tomasnorre / crawler / 18850473052

27 Oct 2025 05:38PM UTC coverage: 69.33% (-0.2%) from 69.481%
18850473052

Pull #1158

github

web-flow
Merge bd10b1ec2 into 9bc42f52b
Pull Request #1158: [TASK] Replace deprecated applicationData with request attributes

12 of 15 new or added lines in 1 file covered. (80.0%)

8 existing lines in 3 files now uncovered.

1935 of 2791 relevant lines covered (69.33%)

3.22 hits per line

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

67.44
/Classes/Service/PageService.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace AOE\Crawler\Service;
6

7
/*
8
 * (c) 2021 AOE GmbH <dev@aoe.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\Configuration\ExtensionConfigurationProvider;
23
use AOE\Crawler\Event\ModifySkipPageEvent;
24
use TYPO3\CMS\Core\Domain\Repository\PageRepository;
25
use TYPO3\CMS\Core\EventDispatcher\EventDispatcher;
26
use TYPO3\CMS\Core\Information\Typo3Version;
27
use TYPO3\CMS\Core\Utility\GeneralUtility;
28

29
/**
30
 * @internal since v9.2.5
31
 */
32
class PageService
33
{
34
    private readonly EventDispatcher $eventDispatcher;
35

36
    public function __construct(?EventDispatcher $eventDispatcher = null)
37
    {
38
        $this->eventDispatcher = $eventDispatcher ?? GeneralUtility::makeInstance(EventDispatcher::class);
16✔
39
    }
40

41
    /**
42
     * Check if the given page should be crawled
43
     *
44
     * @return false|string false if the page should be crawled (not excluded), true / skipMessage if it should be skipped
45
     */
46
    public function checkIfPageShouldBeSkipped(array $pageRow): false|string
47
    {
48
        $extensionSettings = GeneralUtility::makeInstance(
16✔
49
            ExtensionConfigurationProvider::class
16✔
50
        )->getExtensionConfiguration();
16✔
51

52
        // if page is hidden
53
        if (!($extensionSettings['crawlHiddenPages'] ?? false) && ($pageRow['hidden'] ?? false)) {
16✔
54
            return 'Because page is hidden';
2✔
55
        }
56

57
        if (in_array($pageRow['doktype'], $this->getDisallowedDokTypes(), true)) {
15✔
58
            return sprintf('Because doktype "%d" is not allowed', $pageRow['doktype']);
4✔
59
        }
60

61
        foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['excludeDoktype'] ?? [] as $key => $doktypeList) {
11✔
62
            if (GeneralUtility::inList($doktypeList, $pageRow['doktype'])) {
1✔
63
                return sprintf(
1✔
64
                    'Doktype "%d" was excluded by excludeDoktype configuration key "%s"',
1✔
65
                    $pageRow['doktype'],
1✔
66
                    $key
1✔
67
                );
1✔
68
            }
69
        }
70

71
        // veto hook
72
        foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['pageVeto'] ?? [] as $key => $func) {
10✔
73
            trigger_error(
×
74
                'The pageVeto-hook of the TYPO3 Crawler is deprecated since v11.0.0 and will be removed in v13.0,
×
75
                please use the PSR-14 ModifySkipPageEvent instead.',
×
76
                E_USER_DEPRECATED
×
77
            );
×
78

79
            $params = [
×
80
                'pageRow' => $pageRow,
×
81
            ];
×
82
            // expects "false" if page is ok and "true" or a skipMessage if this page should _not_ be crawled
83
            $veto = GeneralUtility::callUserFunction($func, $params, $this);
×
84
            if ($veto !== false) {
×
85
                if (is_string($veto)) {
×
86
                    return $veto;
×
87
                }
88
                return 'Veto from hook "' . htmlspecialchars((string) $key) . '"';
×
89
            }
90
        }
91

92
        /** @var ModifySkipPageEvent $event */
93
        $event = $this->eventDispatcher->dispatch(new ModifySkipPageEvent($pageRow));
10✔
94
        return $event->isSkipped();
10✔
95
    }
96

97
    private function getDisallowedDokTypes(): array
98
    {
99
        return array_merge([
15✔
100
            PageRepository::DOKTYPE_LINK,
15✔
101
            PageRepository::DOKTYPE_SHORTCUT,
15✔
102
            PageRepository::DOKTYPE_SPACER,
15✔
103
            PageRepository::DOKTYPE_SYSFOLDER,
15✔
104
            PageRepository::DOKTYPE_BE_USER_SECTION,
15✔
105
        ], $this->getDisallowedDokTypeTYPO3v12());
15✔
106
    }
107

108
    private function getDisallowedDokTypeTYPO3v12(): array
109
    {
110
        $disallowed_v12 = [];
15✔
111
        $typo3Version = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(Typo3Version::class);
15✔
112
        if ($typo3Version->getMajorVersion() === 12) {
15✔
UNCOV
113
            $disallowed_v12[] = PageRepository::DOKTYPE_RECYCLER;
×
114
        }
115
        return $disallowed_v12;
15✔
116
    }
117
}
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