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

Yoast / Yoast-SEO-for-TYPO3 / 13327579701

14 Feb 2025 10:43AM UTC coverage: 1.276%. First build
13327579701

push

github

web-flow
Merge pull request #597 from Yoast/feature/v11

[FEATURE] Release 11.0.0

21 of 894 new or added lines in 76 files covered. (2.35%)

35 of 2744 relevant lines covered (1.28%)

0.04 hits per line

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

0.0
/Classes/Widgets/Provider/OrphanedContentDataProvider.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace YoastSeoForTypo3\YoastSeo\Widgets\Provider;
6

7
use TYPO3\CMS\Core\Database\Connection;
8
use TYPO3\CMS\Core\Database\ConnectionPool;
9
use TYPO3\CMS\Core\Type\Bitmask\Permission;
10
use TYPO3\CMS\Core\Utility\GeneralUtility;
11
use YoastSeoForTypo3\YoastSeo\Traits\BackendUserTrait;
12

13
class OrphanedContentDataProvider implements PageProviderInterface
14
{
15
    use BackendUserTrait;
16

17
    public function __construct(
18
        /** @var int[] */
19
        private array $excludedDoktypes,
20
        private int $limit
21
    ) {
22
        $this->limit = $limit ?: 5;
×
23
    }
24

25
    /**
26
     * @return array<int, array<string, mixed>>
27
     */
28
    public function getPages(): array
29
    {
30
        $qb = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
×
31

32
        $constraints = [
×
33
            $qb->expr()->eq('ref_table', $qb->createNamedParameter('pages')),
×
34
            $qb->expr()->notIn(
×
35
                'field',
×
36
                $qb->createNamedParameter([
×
37
                    'l10n_parent',
×
NEW
38
                    'db_mountpoints',
×
39
                ], Connection::PARAM_STR_ARRAY)
×
NEW
40
            ),
×
41
        ];
×
42

43
        $refs = $qb->select('ref_uid')
×
44
            ->from('sys_refindex')
×
45
            ->where(...$constraints)
×
46
            ->groupBy('ref_uid')
×
47
            ->executeQuery()
×
48
            ->fetchAllAssociative();
×
49

50
        $pageIds = [];
×
51
        foreach ($refs as $ref) {
×
52
            $pageIds[] = $ref['ref_uid'];
×
53
        }
54

55
        $items = [];
×
56
        $counter = 0;
×
57
        $iterator = 0;
×
58

59
        $constraints = [];
×
60
        if (count($pageIds)) {
×
61
            $constraints = [
×
62
                $qb->expr()->notIn('p.doktype', $this->excludedDoktypes),
×
63
                $qb->expr()->notIn('p.uid', $pageIds),
×
64
            ];
×
65
        }
66

67
        $qb = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('pages');
×
68
        while ($counter < $this->limit) {
×
69
            $row = $qb->select('p.*')
×
70
                ->from('pages', 'p')
×
71
                ->where(...$constraints)
×
72
                ->orderBy('tstamp', 'DESC')
×
73
                ->setFirstResult($iterator)
×
74
                ->setMaxResults(1)
×
75
                ->executeQuery()
×
76
                ->fetchAssociative();
×
77

78
            if ($row === false) {
×
79
                // Likely fewer pages than the limit, prevent infinite loop
80
                break;
×
81
            }
82

83
            $iterator++;
×
84

85
            if (!$this->getBackendUser()->doesUserHaveAccess($row, Permission::PAGE_SHOW)) {
×
86
                continue;
×
87
            }
88

89
            $items[] = $row;
×
90
            $counter++;
×
91
        }
92

93
        return $items;
×
94
    }
95
}
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