Passed
Pull Request — main (#3338)
by
unknown
41:47
created

DataUpdateHandler::removeFromIndexAndQueue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace ApacheSolrForTypo3\Solr\Domain\Index\Queue\UpdateHandler;
19
20
use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\ConfigurationAwareRecordService;
21
use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\MountPagesUpdater;
22
use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\RootPageResolver;
23
use ApacheSolrForTypo3\Solr\Domain\Site\SiteInterface;
24
use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository;
25
use ApacheSolrForTypo3\Solr\FrontendEnvironment;
26
use ApacheSolrForTypo3\Solr\IndexQueue\Queue;
27
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
28
use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager;
29
use ApacheSolrForTypo3\Solr\System\Records\Pages\PagesRepository;
30
use ApacheSolrForTypo3\Solr\System\TCA\TCAService;
31
use ApacheSolrForTypo3\Solr\Util;
32
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
33
use Doctrine\DBAL\Exception as DBALException;
34
use InvalidArgumentException;
35
use Throwable;
36
use TYPO3\CMS\Backend\Utility\BackendUtility;
37
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
38
use TYPO3\CMS\Core\DataHandling\DataHandler;
39
use TYPO3\CMS\Core\Utility\GeneralUtility;
40
41
/**
42
 * Data update handler
43
 *
44
 * Handles update on potential relevant records e.g.
45
 * an update might require index queue updates
46
 */
47
class DataUpdateHandler extends AbstractUpdateHandler
48
{
49
    /**
50
     * List of fields in the update field array that
51
     * are required for processing
52
     *
53
     * Note: For pages all fields except l10n_diffsource are
54
     *       kept, as additional fields can be configured in
55
     *       TypoScript, see AbstractDataUpdateEvent->_sleep.
56
     *
57
     * @var array
58
     */
59
    protected static array $requiredUpdatedFields = [
60
        'pid',
61
    ];
62
63
    /**
64
     * Configuration used to check if recursive updates are required
65
     *
66
     * Holds the configuration when a recursive page queuing should be triggered, while processing record
67
     * updates
68
     *
69
     * Note: The SQL transaction is already committed, so the current state covers only "non"-changed fields.
70
     *
71
     * @var array
72
     */
73
    protected array $updateSubPagesRecursiveTriggerConfiguration = [
74
        // the current page has the both fields "extendToSubpages" and "hidden" set from 1 to 0 => requeue subpages
75
        'HiddenAndExtendToSubpageWereDisabled' => [
76
            'changeSet' => [
77
                'hidden' => '0',
78
                'extendToSubpages' => '0',
79
            ],
80
        ],
81
        // the current page has the field "extendToSubpages" enabled and the field "hidden" was set to 0 => requeue subpages
82
        'extendToSubpageEnabledAndHiddenFlagWasRemoved' => [
83
            'currentState' =>  ['extendToSubpages' => '1'],
84
            'changeSet' => ['hidden' => '0'],
85
        ],
86
        // the current page has the field "hidden" enabled and the field "extendToSubpages" was set to 0 => requeue subpages
87
        'hiddenIsEnabledAndExtendToSubPagesWasRemoved' => [
88
            'currentState' =>  ['hidden' => '1'],
89
            'changeSet' => ['extendToSubpages' => '0'],
90
        ],
91
        // the field "no_search_sub_entries" of current page was set to 0
92
        'no_search_sub_entriesFlagWasAdded' => [
93
            'changeSet' => ['no_search_sub_entries' => '0'],
94
        ],
95
    ];
96
97
    /**
98
     * @var MountPagesUpdater
99
     */
100
    protected MountPagesUpdater $mountPageUpdater;
101
102
    /**
103
     * @var RootPageResolver
104
     */
105
    protected RootPageResolver $rootPageResolver;
106
107
    /**
108
     * @var PagesRepository|null
109
     */
110
    protected ?PagesRepository $pagesRepository;
111
112
    /**
113
     * @var SolrLogManager
114
     */
115
    protected SolrLogManager $logger;
116
117
    /**
118
     * @var DataHandler
119
     */
120
    protected DataHandler $dataHandler;
121
122
    /**
123
     * @param ConfigurationAwareRecordService $recordService
124
     * @param FrontendEnvironment $frontendEnvironment
125
     * @param TCAService $tcaService
126
     * @param Queue $indexQueue
127
     * @param MountPagesUpdater $mountPageUpdater
128
     * @param RootPageResolver $rootPageResolver
129
     * @param PagesRepository $pagesRepository
130
     * @param DataHandler $dataHandler
131
     * @param SolrLogManager|null $solrLogManager
132
     */
133 83
    public function __construct(
134
        ConfigurationAwareRecordService $recordService,
135
        FrontendEnvironment $frontendEnvironment,
136
        TCAService $tcaService,
137
        Queue $indexQueue,
138
        MountPagesUpdater $mountPageUpdater,
139
        RootPageResolver $rootPageResolver,
140
        PagesRepository $pagesRepository,
141
        DataHandler $dataHandler,
142
        SolrLogManager $solrLogManager = null
143
    ) {
144 83
        parent::__construct($recordService, $frontendEnvironment, $tcaService, $indexQueue);
145
146 83
        $this->mountPageUpdater = $mountPageUpdater;
147 83
        $this->rootPageResolver = $rootPageResolver;
148 83
        $this->pagesRepository = $pagesRepository;
149 83
        $this->dataHandler = $dataHandler;
150 83
        $this->logger = $solrLogManager ?? GeneralUtility::makeInstance(
151
            SolrLogManager::class,
152
            /** @scrutinizer ignore-type */
153
            __CLASS__
154
        );
155
    }
156
157
    /**
158
     * Handle content element update
159
     *
160
     * @param int $uid
161
     * @param array $updatedFields
162
     * @throws DBALDriverException
163
     * @throws Throwable
164
     */
165 15
    public function handleContentElementUpdate(int $uid, array $updatedFields = []): void
166
    {
167 15
        $pid = $updatedFields['pid'] ?? $this->getValidatedPid('tt_content', $uid);
168 15
        if ($pid === null) {
169 1
            return;
170
        }
171
172 14
        $this->processPageRecord($pid, (int)$pid, $updatedFields);
173
    }
174
175
    /**
176
     * Handles the deletion of a content element
177
     *
178
     * @param int $uid
179
     * @throws AspectNotFoundException
180
     * @throws DBALDriverException
181
     * @throws DBALException|\Doctrine\DBAL\DBALException
182
     * @throws Throwable
183
     */
184 3
    public function handleContentElementDeletion(int $uid): void
185
    {
186
        // @TODO: Should be checked, is possibly unnecessary as
187
        //        also done via GarbageCollector & PageStrategy
188
189 3
        $pid = $this->getValidatedPid('tt_content', $uid);
190 3
        if ($pid === null) {
191
            return;
192
        }
193
194 3
        $this->indexQueue->updateItem('pages', $pid, Util::getExceptionTime());
195
    }
196
197
    /**
198
     * Handles page updates
199
     *
200
     * @param int $uid
201
     * @param array $updatedFields
202
     * @throws DBALDriverException
203
     * @throws Throwable
204
     */
205 44
    public function handlePageUpdate(int $uid, array $updatedFields = []): void
206
    {
207
        if ($uid === 0) {
208 44
            return;
209 2
        }
210 42
        try {
211 9
            if (isset($updatedFields['l10n_parent']) && (int)($updatedFields['l10n_parent']) > 0) {
212
                $pid = $updatedFields['l10n_parent'];
213 42
            } elseif ($this->rootPageResolver->getIsRootPageId($uid)) {
214
                $pid = $uid;
215 2
            } else {
216 2
                $pid = $updatedFields['pid'] ?? $this->getValidatedPid('pages', $uid);
217
            }
218
        } catch (Throwable $e) {
219 44
            $pid = null;
220 2
        }
221 2
222
        if ($pid === null) {
223
            $this->removeFromIndexAndQueueWhenItemInQueue('pages', $uid);
224 42
            return;
225
        }
226
227
        $this->processPageRecord($uid, (int)$pid, $updatedFields);
228
    }
229
230
    /**
231
     * Handles record updates
232
     *
233
     * @param int $uid
234
     * @param string $table
235 13
     * @throws DBALDriverException
236
     * @throws Throwable
237 13
     */
238 13
    public function handleRecordUpdate(int $uid, string $table): void
239
    {
240
        $rootPageIds = $this->getRecordRootPageIds($table, $uid);
241
        $this->processRecord($table, $uid, $rootPageIds);
242
    }
243
244
    /**
245
     * Handles a version swap
246
     *
247
     * @param int $uid
248
     * @param string $table
249
     * @throws DBALDriverException
250 6
     * @throws DBALException|\Doctrine\DBAL\DBALException
251
     * @throws Throwable
252 6
     */
253 6
    public function handleVersionSwap(int $uid, string $table): void
254 4
    {
255 4
        $isPageRelatedRecord = ($table === 'tt_content' || $table === 'pages');
256
        if ($isPageRelatedRecord) {
257
            $uid = ($table === 'tt_content' ? $this->getValidatedPid($table, $uid) : $uid);
258 4
            if ($uid === null) {
259
                return;
260 2
            }
261 2
            $this->applyPageChangesToQueue($uid);
262
        } else {
263
            $recordPageId = $this->getValidatedPid($table, $uid);
264 2
            if ($recordPageId === null) {
265
                return;
266
            }
267
            $this->applyRecordChangesToQueue($table, $uid, $recordPageId);
268
        }
269
    }
270
271
    /**
272
     * Handle page move
273
     *
274
     * @param int $uid
275
     * @throws DBALDriverException
276 1
     * @throws DBALException|\Doctrine\DBAL\DBALException
277
     * @throws Throwable
278 1
     */
279
    public function handleMovedPage(int $uid): void
280
    {
281
        $this->applyPageChangesToQueue($uid);
282
    }
283
284
    /**
285
     * Handle record move
286
     *
287
     * @param int $uid
288
     * @param string $table
289
     * @throws DBALDriverException
290 1
     * @throws DBALException|\Doctrine\DBAL\DBALException
291
     * @throws Throwable
292 1
     */
293 1
    public function handleMovedRecord(int $uid, string $table): void
294
    {
295
        $pid = $this->getValidatedPid($table, $uid);
296
        if ($pid === null) {
297 1
            return;
298
        }
299
300
        $this->applyRecordChangesToQueue($table, $uid, $pid);
301
    }
302
303
    /**
304
     * Adds a page to the queue and updates mounts, when it is enabled, otherwise ensure that the page is removed
305
     * from the queue.
306
     *
307
     * @param int $uid
308
     * @throws DBALDriverException
309 5
     * @throws DBALException|\Doctrine\DBAL\DBALException
310
     * @throws Throwable
311 5
     */
312 5
    protected function applyPageChangesToQueue(int $uid): void
313 5
    {
314 4
        $solrConfiguration = $this->getSolrConfigurationFromPageId($uid);
315 4
        $record = $this->configurationAwareRecordService->getRecord('pages', $uid, $solrConfiguration);
316
        if (!empty($record) && $this->tcaService->isEnabledRecord('pages', $record)) {
317 1
            $this->mountPageUpdater->update($uid);
318
            $this->indexQueue->updateItem('pages', $uid);
319
        } else {
320
            $this->removeFromIndexAndQueueWhenItemInQueue('pages', $uid);
321
        }
322
    }
323
324
    /**
325
     * Adds a record to the queue if it is monitored and enabled, otherwise it removes the record from the queue.
326
     *
327
     * @param string $table
328
     * @param int $uid
329
     * @param int $pid
330
     * @throws DBALDriverException
331 3
     * @throws DBALException|\Doctrine\DBAL\DBALException
332
     * @throws Throwable
333 3
     */
334 3
    protected function applyRecordChangesToQueue(string $table, int $uid, int $pid): void
335
    {
336 3
        $solrConfiguration = $this->getSolrConfigurationFromPageId($pid);
337 3
        $isMonitoredTable = $solrConfiguration->getIndexQueueIsMonitoredTable($table);
338
339 3
        if ($isMonitoredTable) {
340 2
            $record = $this->configurationAwareRecordService->getRecord($table, $uid, $solrConfiguration);
341 2
342
            if (!empty($record) && $this->tcaService->isEnabledRecord($table, $record)) {
343
                $uid = $this->tcaService->getTranslationOriginalUidIfTranslated($table, $record, $uid);
344 1
                $this->indexQueue->updateItem($table, $uid);
345
            } else {
346
                // TODO should be moved to garbage collector
347
                $this->removeFromIndexAndQueueWhenItemInQueue($table, $uid);
348
            }
349
        }
350
    }
351
352
    /**
353
     * Removes record from the index queue and from the solr index
354
     *
355 6
     * @param string $recordTable Name of table where the record lives
356
     * @param int $recordUid id of record
357 6
     */
358
    protected function removeFromIndexAndQueue(string $recordTable, int $recordUid): void
359
    {
360
        $this->getGarbageHandler()->collectGarbage($recordTable, $recordUid);
361
    }
362
363
    /**
364
     * Removes record from the index queue and from the solr index when the item is in the queue.
365
     *
366
     * @param string $recordTable Name of table where the record lives
367
     * @param int $recordUid id of record
368 8
     * @throws DBALDriverException
369
     * @throws DBALException|\Doctrine\DBAL\DBALException
370 8
     */
371 2
    protected function removeFromIndexAndQueueWhenItemInQueue(string $recordTable, int $recordUid): void
372
    {
373
        if (!$this->indexQueue->containsItem($recordTable, $recordUid)) {
374 6
            return;
375
        }
376
377
        $this->removeFromIndexAndQueue($recordTable, $recordUid);
378
    }
379
380
    /**
381
     * @param int $pageId
382 8
     * @return TypoScriptConfiguration
383
     * @throws DBALDriverException
384 8
     */
385
    protected function getSolrConfigurationFromPageId(int $pageId): TypoScriptConfiguration
386
    {
387
        return $this->frontendEnvironment->getSolrConfigurationFromPageId($pageId);
388
    }
389
390
    /**
391
     * Fetch record root page ids
392
     *
393
     * @param string $recordTable The table the record belongs to
394
     * @param int $recordUid
395
     * @return int[]
396 13
     * @throws DBALDriverException
397
     * @throws Throwable
398
     */
399 13
    protected function getRecordRootPageIds(string $recordTable, int $recordUid): array
400
    {
401
        try {
402
            $rootPageIds = $this->rootPageResolver->getResponsibleRootPageIds($recordTable, $recordUid);
403
        } catch (InvalidArgumentException $e) {
404 13
            $rootPageIds = [];
405
        }
406
407
        return $rootPageIds;
408
    }
409
410
    /**
411
     * Processes a page record
412
     *
413
     * Note: Also used if content element is updated, the page
414
     * of the content element is processed here
415
     *
416
     * @param int $uid
417
     * @param int $pid
418
     * @param array $updatedFields
419 56
     * @throws DBALDriverException
420
     * @throws Throwable
421 56
     */
422 56
    protected function processPageRecord(int $uid, int $pid, array $updatedFields = []): void
423 2
    {
424 2
        $configurationPageId = $this->getConfigurationPageId('pages', $pid, $uid);
425
        if ($configurationPageId === 0) {
426 54
            $this->mountPageUpdater->update($uid);
427
            return;
428 54
        }
429
        $rootPageIds = [$configurationPageId];
430 54
431 54
        $this->processRecord('pages', $uid, $rootPageIds);
432
433 54
        $this->updateCanonicalPages($uid);
434 54
        $this->mountPageUpdater->update($uid);
435 12
436 12
        $recursiveUpdateRequired = $this->isRecursivePageUpdateRequired($uid, $updatedFields);
437
        if ($recursiveUpdateRequired) {
438
            $treePageIds = $this->getSubPageIds($uid);
439
            $this->updatePageIdItems($treePageIds);
440
        }
441
    }
442
443
    /**
444
     * Process a record
445
     *
446
     * @param string $recordTable
447
     * @param int $recordUid
448
     * @param array $rootPageIds
449
     * @throws DBALDriverException
450 67
     * @throws DBALException|\Doctrine\DBAL\DBALException
451
     * @throws Throwable
452 67
     */
453
    protected function processRecord(string $recordTable, int $recordUid, array $rootPageIds): void
454
    {
455
        if (empty($rootPageIds)) {
456
            $this->removeFromIndexAndQueueWhenItemInQueue($recordTable, $recordUid);
457 67
            return;
458 67
        }
459 67
460
        foreach ($rootPageIds as $configurationPageId) {
461
            $site = $this->getSiteRepository()->getSiteByPageId($configurationPageId);
462 67
            if (!$site instanceof SiteInterface) {
463 67
                continue;
464 67
            }
465
            $solrConfiguration = $site->getSolrConfiguration();
466 1
            $isMonitoredRecord = $solrConfiguration->getIndexQueueIsMonitoredTable($recordTable);
467
            if (!$isMonitoredRecord) {
468
                // when it is a non monitored record, we can skip it.
469 66
                continue;
470 66
            }
471
472
            $record = $this->configurationAwareRecordService->getRecord($recordTable, $recordUid, $solrConfiguration);
473 4
            if (empty($record)) {
474 4
                // TODO move this part to the garbage collector
475
                // check if the item should be removed from the index because it no longer matches the conditions
476
                $this->removeFromIndexAndQueueWhenItemInQueue($recordTable, $recordUid);
477
                continue;
478
            }
479 64
            // Clear existing index queue items to prevent mount point duplicates.
480 64
            // This needs to be done before the overlay handling, because handling an overlay record should
481 49
            // not trigger a deletion.
482
            $isTranslation = !empty($record['sys_language_uid']) && $record['sys_language_uid'] !== 0;
483
            if ($recordTable === 'pages' && !$isTranslation) {
484
                $this->indexQueue->deleteItem('pages', $recordUid);
485 64
            }
486 64
487
            // The pages localized record can not consist without l10n_parent, so apply "free-content-mode" on records only.
488
            if ($recordTable === 'pages' || !$site->hasFreeContentModeLanguages() || !in_array($record['sys_language_uid'], $site->getFreeContentModeLanguages())) {
0 ignored issues
show
Bug introduced by
The method getFreeContentModeLanguages() does not exist on ApacheSolrForTypo3\Solr\Domain\Site\SiteInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to ApacheSolrForTypo3\Solr\Domain\Site\SiteInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

488
            if ($recordTable === 'pages' || !$site->hasFreeContentModeLanguages() || !in_array($record['sys_language_uid'], $site->/** @scrutinizer ignore-call */ getFreeContentModeLanguages())) {
Loading history...
Bug introduced by
The method hasFreeContentModeLanguages() does not exist on ApacheSolrForTypo3\Solr\Domain\Site\SiteInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to ApacheSolrForTypo3\Solr\Domain\Site\SiteInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

488
            if ($recordTable === 'pages' || !$site->/** @scrutinizer ignore-call */ hasFreeContentModeLanguages() || !in_array($record['sys_language_uid'], $site->getFreeContentModeLanguages())) {
Loading history...
489
                $recordUid = $this->tcaService->getTranslationOriginalUidIfTranslated($recordTable, $record, $recordUid);
490 64
            }
491
492 64
            // only update/insert the item if we actually found a record
493
            $isLocalizedRecord = $this->tcaService->isLocalizedRecord($recordTable, $record);
494
495
            if ($isLocalizedRecord && !$this->getIsTranslationParentRecordEnabled($recordTable, $recordUid)) {
0 ignored issues
show
Bug introduced by
It seems like $recordUid can also be of type null; however, parameter $recordUid of ApacheSolrForTypo3\Solr\...onParentRecordEnabled() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

495
            if ($isLocalizedRecord && !$this->getIsTranslationParentRecordEnabled($recordTable, /** @scrutinizer ignore-type */ $recordUid)) {
Loading history...
496
                // we have a localized record without a visible parent record. Nothing to do.
497 64
                continue;
498 58
            }
499
500
            if ($this->tcaService->isEnabledRecord($recordTable, $record)) {
501
                $this->indexQueue->updateItem($recordTable, $recordUid);
502
            }
503
        }
504
    }
505
506
    /**
507
     * This method is used to determine the pageId that should be used to retrieve the index queue configuration.
508
     *
509
     * @param string $recordTable
510
     * @param int $recordPageId
511
     * @param int $recordUid
512
     * @return int
513 56
     * @throws DBALDriverException
514
     * @throws Throwable
515 56
     */
516 56
    protected function getConfigurationPageId(string $recordTable, int $recordPageId, int $recordUid): int
517 56
    {
518 56
        $rootPageId = $this->rootPageResolver->getRootPageId($recordPageId);
519 56
        $rootPageRecord = $this->getPagesRepository()->getPage($rootPageId);
520 56
        if (isset($rootPageRecord['sys_language_uid'])
521
            && (int)$rootPageRecord['sys_language_uid'] > 0
522 2
            && isset($rootPageRecord['l10n_parent'])
523
            && (int)$rootPageRecord['l10n_parent'] > 0
524 56
        ) {
525 54
            $rootPageId = $recordPageId = $rootPageRecord['l10n_parent'];
526
        }
527
        if ($this->rootPageResolver->getIsRootPageId($rootPageId)) {
528 2
            return $recordPageId;
529
        }
530
531
        $alternativeSiteRoots = $this->rootPageResolver->getAlternativeSiteRootPagesIds(
532
            $recordTable,
533 2
            $recordUid,
534
            $recordPageId
535
        );
536
        return (int)array_pop($alternativeSiteRoots);
537
    }
538
539
    /**
540
     * Checks if the parent record of the translated record is enabled.
541
     *
542
     * @param string $recordTable
543 3
     * @param int $recordUid
544
     * @return bool
545 3
     */
546 3
    protected function getIsTranslationParentRecordEnabled(string $recordTable, int $recordUid): bool
547
    {
548
        $l10nParentRecord = (array)BackendUtility::getRecord($recordTable, $recordUid, '*', '', false);
549
        return $this->tcaService->isEnabledRecord($recordTable, $l10nParentRecord);
550
    }
551
552
    /**
553
     * Applies the updateItem instruction on a collection of pageIds.
554
     *
555
     * @param array $treePageIds
556
     * @throws DBALDriverException
557 12
     * @throws DBALException|\Doctrine\DBAL\DBALException
558
     * @throws Throwable
559 12
     */
560 10
    protected function updatePageIdItems(array $treePageIds): void
561
    {
562
        foreach ($treePageIds as $treePageId) {
563
            $this->indexQueue->updateItem('pages', $treePageId);
564
        }
565
    }
566
567
    /**
568
     * Triggers Index Queue updates for other pages showing content from the
569
     * page currently being updated.
570
     *
571
     * @param int $pageId UID of the page currently being updated
572
     * @throws DBALDriverException
573 54
     * @throws DBALException|\Doctrine\DBAL\DBALException
574
     * @throws Throwable
575 54
     */
576 54
    protected function updateCanonicalPages(int $pageId): void
577
    {
578
        $canonicalPages = $this->pagesRepository->findPageUidsWithContentsFromPid($pageId);
0 ignored issues
show
Bug introduced by
The method findPageUidsWithContentsFromPid() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

578
        /** @scrutinizer ignore-call */ 
579
        $canonicalPages = $this->pagesRepository->findPageUidsWithContentsFromPid($pageId);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
579
        foreach ($canonicalPages as $page) {
580
            $this->indexQueue->updateItem('pages', $page['uid']);
581
        }
582
    }
583
584
    /**
585
     * Retrieves the pid of a record, returns null if no pid could be found
586
     *
587
     * @param string $table
588 46
     * @param int $uid
589
     * @return int|null
590 46
     */
591 46
    protected function getValidatedPid(string $table, int $uid): ?int
592 1
    {
593 1
        $pid = $this->dataHandler->getPID($table, $uid);
594 1
        if ($pid === false) {
595
            $message = 'Record without valid pid was processed ' . $table . ':' . $uid;
596
            $this->logger->log(SolrLogManager::WARNING, $message);
597 45
            return null;
598
        }
599
600
        return $pid;
601
    }
602
603 6
    /**
604
     * @return GarbageHandler
605 6
     */
606
    protected function getGarbageHandler(): GarbageHandler
607
    {
608
        return GeneralUtility::makeInstance(GarbageHandler::class);
609
    }
610
611 67
    /**
612
     * @return SiteRepository
613 67
     */
614
    protected function getSiteRepository(): SiteRepository
615
    {
616
        return GeneralUtility::makeInstance(SiteRepository::class);
617
    }
618
}
619