| 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\IndexQueue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\QueueInitializationService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\QueueItemRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Exception\RootPageRecordNotFoundException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\ConfigurationAwareRecordService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\RootPageResolver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\Statistic\QueueStatistic; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\Statistic\QueueStatisticsRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use ApacheSolrForTypo3\Solr\Domain\Site\Site; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use ApacheSolrForTypo3\Solr\Domain\Site\SiteRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use ApacheSolrForTypo3\Solr\FrontendEnvironment; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use ApacheSolrForTypo3\Solr\System\Cache\TwoLevelCache; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use Doctrine\DBAL\ConnectionException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use Doctrine\DBAL\Driver\Exception as DBALDriverException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | use Doctrine\DBAL\Exception as DBALException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | use Throwable; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | use TYPO3\CMS\Backend\Utility\BackendUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | use TYPO3\CMS\Core\Utility\GeneralUtility; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |  * The Indexing Queue. It allows us to decouple from frontend indexing and | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  * reacting to the changes faster. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  * @author Ingo Renner <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | class Queue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @var RootPageResolver | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     protected RootPageResolver $rootPageResolver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      * @var ConfigurationAwareRecordService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     protected ConfigurationAwareRecordService $recordService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * @var SolrLogManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     protected SolrLogManager $logger; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * @var QueueItemRepository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     protected QueueItemRepository $queueItemRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * @var QueueStatisticsRepository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     protected QueueStatisticsRepository $queueStatisticsRepository; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      * @var QueueInitializationService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     protected QueueInitializationService $queueInitializationService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * @var FrontendEnvironment | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     protected FrontendEnvironment $frontendEnvironment; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      * Queue constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * @param RootPageResolver|null $rootPageResolver | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * @param ConfigurationAwareRecordService|null $recordService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * @param QueueItemRepository|null $queueItemRepository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * @param QueueStatisticsRepository|null $queueStatisticsRepository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * @param QueueInitializationService|null $queueInitializationService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 | 153 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         RootPageResolver $rootPageResolver = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         ConfigurationAwareRecordService $recordService = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         QueueItemRepository $queueItemRepository = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         QueueStatisticsRepository $queueStatisticsRepository = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         QueueInitializationService $queueInitializationService = null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         FrontendEnvironment $frontendEnvironment = null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 | 153 |  |     ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 | 153 |  |         $this->logger = GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 | 153 |  |         $this->rootPageResolver = $rootPageResolver ?? GeneralUtility::makeInstance(RootPageResolver::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 | 153 |  |         $this->recordService = $recordService ?? GeneralUtility::makeInstance(ConfigurationAwareRecordService::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 | 153 |  |         $this->queueItemRepository = $queueItemRepository ?? GeneralUtility::makeInstance(QueueItemRepository::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 | 153 |  |         $this->queueStatisticsRepository = $queueStatisticsRepository ??  GeneralUtility::makeInstance(QueueStatisticsRepository::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 | 153 |  |         $this->queueInitializationService = $queueInitializationService ?? GeneralUtility::makeInstance(QueueInitializationService::class, /** @scrutinizer ignore-type */ $this); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $this->frontendEnvironment = $frontendEnvironment ?? GeneralUtility::makeInstance(FrontendEnvironment::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     // FIXME some of the methods should be renamed to plural forms | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     // FIXME singular form methods should deal with exactly one item only | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * Returns the timestamp of the last indexing run. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      * @param int $rootPageId The root page uid for which to get | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      *      the last indexed item id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * @return int Timestamp of last index run. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 | 2 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     public function getLastIndexTime(int $rootPageId): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 | 2 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         $lastIndexTime = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         $lastIndexedRow = $this->queueItemRepository->findLastIndexedRow($rootPageId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 | 1 |  |         if ($lastIndexedRow[0]['indexed']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |             $lastIndexTime = $lastIndexedRow[0]['indexed']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         return $lastIndexTime; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * Returns the uid of the last indexed item in the queue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      * @param int $rootPageId The root page uid for which to get | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      *      the last indexed item id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      * @return int The last indexed item's ID. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 | 3 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     public function getLastIndexedItemId(int $rootPageId): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 | 3 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         $lastIndexedItemId = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 | 3 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 | 3 |  |         $lastIndexedItemRow = $this->queueItemRepository->findLastIndexedRow($rootPageId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 | 2 |  |         if ($lastIndexedItemRow[0]['uid']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |             $lastIndexedItemId = $lastIndexedItemRow[0]['uid']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 | 3 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         return $lastIndexedItemId; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |      * @return QueueInitializationService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 | 6 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     public function getInitializationService(): QueueInitializationService | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 | 6 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         return $this->queueInitializationService; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |      * Marks an item as needing (re)indexing. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |      * Like with Solr itself, there's no add method, just a simple update method | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |      * that handles the adds, too. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |      * The method creates or updates the index queue items for all related rootPageIds. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      * @param string $itemType The item's type, usually a table name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * @param int|string $itemUid The item's uid, usually an integer uid, could be a different value for non-database-record types. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * @param int $forcedChangeTime The change time for the item if set, otherwise value from getItemChangedTime() is used. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      * @return int Number of updated/created items | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |      * @throws Throwable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 | 91 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     public function updateItem(string $itemType, $itemUid, int $forcedChangeTime = 0): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 | 91 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 | 90 |  |         $updateCount = $this->updateOrAddItemForAllRelatedRootPages($itemType, $itemUid, $forcedChangeTime); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         return $this->postProcessIndexQueueUpdateItem($itemType, $itemUid, $updateCount, $forcedChangeTime); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |      * Updates or adds the item for all relevant root pages. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |      * @param string $itemType The item's type, usually a table name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |      * @param int|string $itemUid The item's uid, usually an integer uid, could be a different value for non-database-record types. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |      * @param int $forcedChangeTime The change time for the item if set, otherwise value from getItemChangedTime() is used. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |      * @return int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * @throws Throwable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 | 89 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |     protected function updateOrAddItemForAllRelatedRootPages(string $itemType, $itemUid, int $forcedChangeTime): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 | 89 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 | 89 |  |         $updateCount = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 | 88 |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 | 88 |  |             $rootPageIds = $this->rootPageResolver->getResponsibleRootPageIds($itemType, $itemUid); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 | 88 |  |         } catch (RootPageRecordNotFoundException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             $this->deleteItem($itemType, $itemUid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |             return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 | 88 |  |         foreach ($rootPageIds as $rootPageId) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 | 88 |  |             $skipInvalidRootPage = $rootPageId === 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 | 88 |  |             if ($skipInvalidRootPage) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 | 88 |  |                 continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 | 3 |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 | 87 |  |             /* @var SiteRepository $siteRepository */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 | 87 |  |             $siteRepository = GeneralUtility::makeInstance(SiteRepository::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             $solrConfiguration = $siteRepository->getSiteByRootPageId($rootPageId)->getSolrConfiguration(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 | 19 |  |             $indexingConfiguration = $this->recordService->getIndexingConfigurationName($itemType, $itemUid, $solrConfiguration); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 | 19 |  |             if ($indexingConfiguration === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                 continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 | 80 |  |             $itemInQueueForRootPage = $this->containsItemWithRootPageId($itemType, $itemUid, $rootPageId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |             if ($itemInQueueForRootPage) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |                 // update changed time if that item is in the queue already | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 | 87 |  |                 $changedTime = ($forcedChangeTime > 0) ? $forcedChangeTime : $this->getItemChangedTime($itemType, $itemUid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |                 $updatedRows = $this->queueItemRepository->updateExistingItemByItemTypeAndItemUidAndRootPageId($itemType, $itemUid, $rootPageId, $changedTime, $indexingConfiguration); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 | 88 |  |                 // add the item since it's not in the queue yet | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |                 $updatedRows = $this->addNewItem($itemType, $itemUid, $indexingConfiguration, $rootPageId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             $updateCount += $updatedRows; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |         return $updateCount; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |      * Executes the updateItem post-processing hook. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 | 90 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |      * @param string $itemType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |      * @param int|string $itemUid The item's uid, usually an integer uid, could be a different value for non-database-record types. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |      * @param int $updateCount | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |      * @param int $forcedChangeTime | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |      * @return int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 | 90 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 | 89 |  |     protected function postProcessIndexQueueUpdateItem( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |         string $itemType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         $itemUid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 | 1 |  |         int $updateCount, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 | 1 |  |         int $forcedChangeTime = 0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 | 1 |  |     ): int { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |         if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['postProcessIndexQueueUpdateItem'] ?? null)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |             return $updateCount; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 | 1 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['postProcessIndexQueueUpdateItem'] as $classReference) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |             $updateHandler = $this->getHookImplementation($classReference); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |             $updateCount = $updateHandler->postProcessIndexQueueUpdateItem($itemType, $itemUid, $updateCount, $forcedChangeTime); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         return $updateCount; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |      * @param string $classReference | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |      * @return object | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 263 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 264 |  |  |     protected function getHookImplementation(string $classReference): object | 
            
                                                                        
                            
            
                                    
            
            
                | 265 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 266 |  |  |         return GeneralUtility::makeInstance($classReference); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 | 3 |  |      * Finds indexing errors for the current site | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 | 3 |  |      * @param Site $site | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |      * @return array Error items for the current site's Index Queue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |     public function getErrorsBySite(Site $site): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |         return $this->queueItemRepository->findErrorsBySite($site); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 | 1 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 | 1 |  |      * Resets all the errors for all index queue items. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |     public function resetAllErrors() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         return $this->queueItemRepository->flushAllErrors(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 | 1 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |      * Resets the errors in the index queue for a specific site | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 | 1 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |      * @param Site $site | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |     public function resetErrorsBySite(Site $site) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |         return $this->queueItemRepository->flushErrorsBySite($site); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 | 1 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * Resets the error in the index queue for a specific item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 | 1 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |      * @param Item $item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |     public function resetErrorByItem(Item $item) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         return $this->queueItemRepository->flushErrorByItem($item); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |      * Adds an item to the index queue. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |      * Not meant for public use. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |      * @param string $itemType The item's type, usually a table name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |      * @param int|string $itemUid The item's uid, usually an integer uid, could be a | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |      *      different value for non-database-record types. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 | 80 |  |      * @param string $indexingConfiguration The item's indexing configuration to use. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |      *      Optional, overwrites existing / determined configuration. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |      * @param int $rootPageId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |      * @return int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 | 80 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 | 80 |  |     private function addNewItem( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 | 52 |  |         string $itemType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |         $itemUid, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |         string $indexingConfiguration, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 | 80 |  |         int $rootPageId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |     ): int { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 | 80 |  |         $additionalRecordFields = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |         if ($itemType === 'pages') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |             $additionalRecordFields = ', doktype, uid'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 | 80 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |         $record = $this->getRecordCached($itemType, $itemUid, $additionalRecordFields); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 | 80 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |         if (empty($record) || ($itemType === 'pages' && !$this->frontendEnvironment->isAllowedPageType($record, $indexingConfiguration))) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |             return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |         $changedTime = $this->getItemChangedTime($itemType, $itemUid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |         return $this->queueItemRepository->add($itemType, $itemUid, $rootPageId, $changedTime, $indexingConfiguration); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |      * Get record to be added in addNewItem | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 | 80 |  |      * @param string $itemType The item's type, usually a table name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |      * @param int|string $itemUid The item's uid, usually an integer uid, could be a | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 | 80 |  |      *      different value for non-database-record types. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 | 80 |  |      * @param string $additionalRecordFields for sql-query | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 | 80 |  |      * @return array|null | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 | 80 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 | 80 |  |     protected function getRecordCached(string $itemType, $itemUid, string $additionalRecordFields): ?array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 | 80 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |         $cache = GeneralUtility::makeInstance(TwoLevelCache::class, /** @scrutinizer ignore-type */ 'runtime'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |         $cacheId = md5('Queue' . ':' . 'getRecordCached' . ':' . $itemType . ':' . $itemUid . ':' . 'pid' . $additionalRecordFields); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 | 80 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         $record = $cache->get($cacheId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |         if (empty($record)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |             $record = BackendUtility::getRecord($itemType, $itemUid, 'pid' . $additionalRecordFields); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |             $cache->set($cacheId, $record); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |         return $record; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |      * Determines the time for when an item should be indexed. This timestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |      * is then stored in the changed column in the Index Queue. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |      * The changed timestamp usually is now - time(). For records which are set | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |      * to published at a later time, this timestamp is the start time. So if a | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |      * future start time has been set, that will be used to delay indexing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |      * of an item. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 | 87 |  |      * @param string $itemType The item's table name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |      * @param int|string $itemUid The item's uid, usually an integer uid, could be a | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 | 87 |  |      *      different value for non-database-record types. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 | 87 |  |      * @return int Timestamp of the item's changed time or future start time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 | 87 |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 | 87 |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 | 87 |  |     protected function getItemChangedTime(string $itemType, $itemUid): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 | 87 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 | 87 |  |         $itemTypeHasStartTimeColumn = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |         $changedTimeColumns = $GLOBALS['TCA'][$itemType]['ctrl']['tstamp']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 | 87 |  |         $startTime = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |         $pageChangedTime = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 | 59 |  |         if (!empty($GLOBALS['TCA'][$itemType]['ctrl']['enablecolumns']['starttime'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |             $itemTypeHasStartTimeColumn = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |             $changedTimeColumns .= ', ' . $GLOBALS['TCA'][$itemType]['ctrl']['enablecolumns']['starttime']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 | 87 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 | 87 |  |         if ($itemType === 'pages') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |             // does not carry time information directly, but needed to support | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 | 87 |  |             // canonical pages | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 | 87 |  |             $changedTimeColumns .= ', content_from_pid'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 | 87 |  |         $record = BackendUtility::getRecord($itemType, $itemUid, $changedTimeColumns); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 | 59 |  |         $itemChangedTime = $record[$GLOBALS['TCA'][$itemType]['ctrl']['tstamp']]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |         if ($itemTypeHasStartTimeColumn) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 | 59 |  |             $startTime = $record[$GLOBALS['TCA'][$itemType]['ctrl']['enablecolumns']['starttime']]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 | 87 |  |         if ($itemType === 'pages') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |             $record['uid'] = $itemUid; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |             // overrule the page's last changed time with the most recent | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |             //content element change | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |             $pageChangedTime = $this->getPageItemChangedTime($record); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 | 87 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 | 87 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 | 87 |  |         $localizationsChangedTime = $this->queueItemRepository->getLocalizableItemChangedTime($itemType, (int)$itemUid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 | 87 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 | 87 |  |         // if start time exists and start time is higher than last changed timestamp | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 | 87 |  |         // then set changed to the future start time to make the item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |         // indexed at a later time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |         return (int)max( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |             $itemChangedTime, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |             $pageChangedTime, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |             $localizationsChangedTime, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |             $startTime | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 | 59 |  |      * Gets the most recent changed time of a page's content elements | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 | 59 |  |      * @param array $page Partial page record | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |      * @return int Timestamp of the most recent content element change | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 | 59 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |     protected function getPageItemChangedTime(array $page): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |         if (!empty($page['content_from_pid'])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |             // canonical page, get the original page's last changed time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |             return $this->queueItemRepository->getPageItemChangedTimeByPageUid((int)$page['content_from_pid']); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |         return $this->queueItemRepository->getPageItemChangedTimeByPageUid((int)$page['uid']) ?? 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |      * Checks whether the Index Queue contains a specific item. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 | 10 |  |      * @param string $itemType The item's type, usually a table name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |      * @param int|string $itemUid The item's uid, usually an integer uid, could be a | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 | 10 |  |      *      different value for non-database-record types. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |      * @return bool TRUE if the item is found in the queue, FALSE otherwise | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |     public function containsItem(string $itemType, $itemUid): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |         return $this->queueItemRepository->containsItem($itemType, (int)$itemUid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |      * Checks whether the Index Queue contains a specific item. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |      * @param string $itemType The item's type, usually a table name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 | 87 |  |      * @param int|string $itemUid The item's uid, usually an integer uid, could be a | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |      *      different value for non-database-record types. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 | 87 |  |      * @param int $rootPageId | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |      * @return bool TRUE if the item is found in the queue, FALSE otherwise | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |     public function containsItemWithRootPageId(string $itemType, $itemUid, int $rootPageId): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |         return $this->queueItemRepository->containsItemWithRootPageId($itemType, (int)$itemUid, $rootPageId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |      * Checks whether the Index Queue contains a specific item that has been | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |      * marked as indexed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |      * @param string $itemType The item's type, usually a table name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 | 4 |  |      * @param int|string $itemUid The item's uid, usually an integer uid, could be a | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |      *      different value for non-database-record types. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 | 4 |  |      * @return bool TRUE if the item is found in the queue and marked as | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |      *      indexed, FALSE otherwise | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |     public function containsIndexedItem(string $itemType, $itemUid): bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |         return $this->queueItemRepository->containsIndexedItem($itemType, (int)$itemUid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |      * Removes an item from the Index Queue. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 | 57 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |      * @param string $itemType The type of the item to remove, usually a table name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 | 57 |  |      * @param int|string $itemUid The uid of the item to remove | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |      * @throws ConnectionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |      * @throws DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |      * @throws Throwable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |     public function deleteItem(string $itemType, $itemUid) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |         $this->queueItemRepository->deleteItem($itemType, (int)$itemUid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 | 1 |  |      * Removes all items of a certain type from the Index Queue. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 | 1 |  |      * @param string $itemType The type of items to remove, usually a table name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |      * @throws ConnectionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |      * @throws DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |      * @throws Throwable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |     public function deleteItemsByType(string $itemType) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |         $this->queueItemRepository->deleteItemsByType($itemType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |      * Removes all items of a certain site from the Index Queue. Accepts an | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |      * optional parameter to limit the deleted items by indexing configuration. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 | 6 |  |      * @param Site $site The site to remove items for. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |      * @param string $indexingConfigurationName Name of a specific indexing | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 | 6 |  |      *      configuration | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |      * @throws ConnectionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |      * @throws \Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |      * @throws Throwable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |     public function deleteItemsBySite(Site $site, string $indexingConfigurationName = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |         $this->queueItemRepository->deleteItemsBySite($site, $indexingConfigurationName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |      * Removes all items from the Index Queue. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |     public function deleteAllItems() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |         $this->queueItemRepository->deleteAllItems(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 | 34 |  |      * Gets a single Index Queue item by its uid. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 | 34 |  |      * @param int $itemId Index Queue item uid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |      * @return Item|null The request Index Queue item or NULL if no item with $itemId was found | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |     public function getItem(int $itemId): ?Item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |         return $this->queueItemRepository->findItemByUid($itemId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |      * Gets Index Queue items by type and uid. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |      * @param string $itemType item type, usually  the table name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 | 49 |  |      * @param int|string $itemUid item uid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |      * @return Item[] An array of items matching $itemType and $itemUid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 | 49 |  |      * @throws ConnectionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |      * @throws DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |      * @throws Throwable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |     public function getItems(string $itemType, $itemUid): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |         return $this->queueItemRepository->findItemsByItemTypeAndItemUid($itemType, (int)$itemUid); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |      * Returns all items in the queue. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 | 4 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |      * @return Item[] An array of items | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 | 4 |  |      * @throws ConnectionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |      * @throws DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |      * @throws Throwable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |     public function getAllItems(): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |         return $this->queueItemRepository->findAll(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 | 111 |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |      * Returns the number of items for all queues. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 | 111 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |      * @return int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |      * @throws DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |     public function getAllItemsCount(): int | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |         return $this->queueItemRepository->count(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |      * Extracts the number of pending, indexed and erroneous items from the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |      * Index Queue. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 | 5 |  |      * @param Site $site | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |      * @param string $indexingConfigurationName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 | 5 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 | 5 |  |      * @return QueueStatistic | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 | 5 |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 | 5 |  |      * @throws DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 | 5 |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |     public function getStatisticsBySite(Site $site, string $indexingConfigurationName = ''): QueueStatistic | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |         return $this->queueStatisticsRepository | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |             ->findOneByRootPidAndOptionalIndexingConfigurationName( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |                 $site->getRootPageId(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |                 $indexingConfigurationName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |      * Gets $limit number of items to index for a particular $site. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |      * @param Site $site TYPO3 site | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 | 3 |  |      * @param int $limit Number of items to get from the queue | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |      * @return Item[] Items to index to the given solr server | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 | 3 |  |      * @throws ConnectionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  |      * @throws DBALDriverException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |      * @throws DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |      * @throws Throwable | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |     public function getItemsToIndex(Site $site, int $limit = 50): array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |         return $this->queueItemRepository->findItemsToIndex($site, $limit); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 | 6 |  |      * Marks an item as failed and causes the indexer to skip the item in the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |      * next run. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 | 6 |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |      * @param int|Item $item Either the item's Index Queue uid or the complete item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |      * @param string $errorMessage Error message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  |     public function markItemAsFailed($item, string $errorMessage = '') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |         $this->queueItemRepository->markItemAsFailed($item, $errorMessage); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 | 2 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 | 2 |  |      * Sets the timestamp of when an item last has been indexed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |      * @param Item $item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  |     public function updateIndexTimeByItem(Item $item) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |         $this->queueItemRepository->updateIndexTimeByItem($item); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |      * Sets the change timestamp of an item. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |      * @param Item $item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |      * @param int $forcedChangeTime The change time for the item | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  |      * @throws DBALException|\Doctrine\DBAL\DBALException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |     public function setForcedChangeTimeByItem(Item $item, int $forcedChangeTime = 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |         $this->queueItemRepository->updateChangedTimeByItem($item, $forcedChangeTime); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 680 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 681 |  |  |  |