1 | <?php |
||
2 | namespace ApacheSolrForTypo3\Solr\IndexQueue; |
||
3 | |||
4 | /*************************************************************** |
||
5 | * Copyright notice |
||
6 | * |
||
7 | * (c) 2009-2015 Ingo Renner <[email protected]> |
||
8 | * All rights reserved |
||
9 | * |
||
10 | * This script is part of the TYPO3 project. The TYPO3 project is |
||
11 | * free software; you can redistribute it and/or modify |
||
12 | * it under the terms of the GNU General Public License as published by |
||
13 | * the Free Software Foundation; either version 3 of the License, or |
||
14 | * (at your option) any later version. |
||
15 | * |
||
16 | * The GNU General Public License can be found at |
||
17 | * http://www.gnu.org/copyleft/gpl.html. |
||
18 | * |
||
19 | * This script is distributed in the hope that it will be useful, |
||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
22 | * GNU General Public License for more details. |
||
23 | * |
||
24 | * This copyright notice MUST APPEAR in all copies of the script! |
||
25 | ***************************************************************/ |
||
26 | |||
27 | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\QueueItemRepository; |
||
28 | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\ConfigurationAwareRecordService; |
||
29 | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\RecordMonitor\Helper\RootPageResolver; |
||
30 | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\Statistic\QueueStatistic; |
||
31 | use ApacheSolrForTypo3\Solr\Domain\Index\Queue\Statistic\QueueStatisticsRepository; |
||
32 | use ApacheSolrForTypo3\Solr\Site; |
||
33 | use ApacheSolrForTypo3\Solr\System\Cache\TwoLevelCache; |
||
34 | use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager; |
||
35 | use ApacheSolrForTypo3\Solr\Util; |
||
36 | use TYPO3\CMS\Backend\Utility\BackendUtility; |
||
0 ignored issues
–
show
|
|||
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 changes faster. |
||
42 | * |
||
43 | * @author Ingo Renner <[email protected]> |
||
44 | */ |
||
45 | class Queue |
||
46 | { |
||
47 | /** |
||
48 | * @var RootPageResolver |
||
49 | */ |
||
50 | protected $rootPageResolver; |
||
51 | |||
52 | /** |
||
53 | * @var ConfigurationAwareRecordService |
||
54 | */ |
||
55 | protected $recordService; |
||
56 | |||
57 | /** |
||
58 | * @var \ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager |
||
59 | */ |
||
60 | protected $logger = null; |
||
61 | |||
62 | /** |
||
63 | * @var QueueItemRepository |
||
64 | */ |
||
65 | protected $queueItemRepository; |
||
66 | |||
67 | /** |
||
68 | * @var QueueStatisticsRepository |
||
69 | */ |
||
70 | protected $queueStatisticsRepository; |
||
71 | |||
72 | /** |
||
73 | * Queue constructor. |
||
74 | * @param RootPageResolver|null $rootPageResolver |
||
75 | * @param ConfigurationAwareRecordService|null $recordService |
||
76 | * @param QueueItemRepository|null $queueItemRepository |
||
77 | * @param QueueStatisticsRepository|null $queueStatisticsRepository |
||
78 | */ |
||
79 | 107 | public function __construct(RootPageResolver $rootPageResolver = null, ConfigurationAwareRecordService $recordService = null, QueueItemRepository $queueItemRepository = null, QueueStatisticsRepository $queueStatisticsRepository = null) |
|
80 | { |
||
81 | 107 | $this->logger = GeneralUtility::makeInstance(SolrLogManager::class, __CLASS__); |
|
82 | 107 | $this->rootPageResolver = isset($rootPageResolver) ? $rootPageResolver : GeneralUtility::makeInstance(RootPageResolver::class); |
|
83 | 107 | $this->recordService = isset($recordService) ? $recordService : GeneralUtility::makeInstance(ConfigurationAwareRecordService::class); |
|
84 | 107 | $this->queueItemRepository = isset($queueItemRepository) ? $queueItemRepository : GeneralUtility::makeInstance(QueueItemRepository::class); |
|
85 | 107 | $this->queueStatisticsRepository = isset($queueStatisticsRepository) ? $queueStatisticsRepository : GeneralUtility::makeInstance(QueueStatisticsRepository::class); |
|
86 | 107 | } |
|
87 | |||
88 | // FIXME some of the methods should be renamed to plural forms |
||
89 | // FIXME singular form methods should deal with exactly one item only |
||
90 | |||
91 | /** |
||
92 | * Returns the timestamp of the last indexing run. |
||
93 | * |
||
94 | * @param int $rootPageId The root page uid for which to get |
||
95 | * the last indexed item id |
||
96 | * @return int Timestamp of last index run. |
||
97 | */ |
||
98 | 2 | public function getLastIndexTime($rootPageId) |
|
99 | { |
||
100 | 2 | $lastIndexTime = 0; |
|
101 | |||
102 | 2 | $lastIndexedRow = $this->queueItemRepository->findLastIndexedRow($rootPageId); |
|
103 | |||
104 | 2 | if ($lastIndexedRow[0]['indexed']) { |
|
105 | 1 | $lastIndexTime = $lastIndexedRow[0]['indexed']; |
|
106 | } |
||
107 | |||
108 | 2 | return $lastIndexTime; |
|
109 | } |
||
110 | |||
111 | /** |
||
112 | * Returns the uid of the last indexed item in the queue |
||
113 | * |
||
114 | * @param int $rootPageId The root page uid for which to get |
||
115 | * the last indexed item id |
||
116 | * @return int The last indexed item's ID. |
||
117 | */ |
||
118 | 3 | public function getLastIndexedItemId($rootPageId) |
|
119 | { |
||
120 | 3 | $lastIndexedItemId = 0; |
|
121 | |||
122 | 3 | $lastIndexedItemRow = $this->queueItemRepository->findLastIndexedRow($rootPageId); |
|
123 | 3 | if ($lastIndexedItemRow[0]['uid']) { |
|
124 | 2 | $lastIndexedItemId = $lastIndexedItemRow[0]['uid']; |
|
125 | } |
||
126 | |||
127 | 3 | return $lastIndexedItemId; |
|
128 | } |
||
129 | |||
130 | /** |
||
131 | * Truncate and rebuild the tx_solr_indexqueue_item table. This is the most |
||
132 | * complete way to force reindexing, or to build the Index Queue for the |
||
133 | * first time. The Index Queue initialization is site-specific. |
||
134 | * |
||
135 | * @param Site $site The site to initialize |
||
136 | * @param string $indexingConfigurationName Name of a specific |
||
137 | * indexing configuration |
||
138 | * @return array An array of booleans, each representing whether the |
||
139 | * initialization for an indexing configuration was successful |
||
140 | */ |
||
141 | 6 | public function initialize(Site $site, $indexingConfigurationName = '') |
|
142 | { |
||
143 | 6 | $indexingConfigurations = []; |
|
144 | 6 | $initializationStatus = []; |
|
145 | |||
146 | 6 | if (empty($indexingConfigurationName)) { |
|
147 | 1 | $solrConfiguration = $site->getSolrConfiguration(); |
|
148 | 1 | $indexingConfigurations = $solrConfiguration->getEnabledIndexQueueConfigurationNames(); |
|
149 | } else { |
||
150 | 5 | $indexingConfigurations[] = $indexingConfigurationName; |
|
151 | } |
||
152 | |||
153 | 6 | foreach ($indexingConfigurations as $indexingConfigurationName) { |
|
154 | 6 | $initializationStatus[$indexingConfigurationName] = $this->initializeIndexingConfiguration( |
|
155 | 6 | $site, |
|
156 | 6 | $indexingConfigurationName |
|
157 | ); |
||
158 | } |
||
159 | |||
160 | 6 | if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['postProcessIndexQueueInitialization'])) { |
|
161 | foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['postProcessIndexQueueInitialization'] as $classReference) { |
||
162 | $indexQueueInitializationPostProcessor = GeneralUtility::makeInstance($classReference); |
||
163 | |||
164 | if ($indexQueueInitializationPostProcessor instanceof InitializationPostProcessor) { |
||
165 | $indexQueueInitializationPostProcessor->postProcessIndexQueueInitialization( |
||
166 | $site, |
||
167 | $indexingConfigurations, |
||
168 | $initializationStatus |
||
169 | ); |
||
170 | } else { |
||
171 | throw new \UnexpectedValueException( |
||
172 | get_class($indexQueueInitializationPostProcessor) . |
||
173 | ' must implement interface ' . InitializationPostProcessor::class, |
||
174 | 1345815561 |
||
175 | ); |
||
176 | } |
||
177 | } |
||
178 | } |
||
179 | |||
180 | 6 | return $initializationStatus; |
|
181 | } |
||
182 | |||
183 | /** |
||
184 | * Initializes the Index Queue for a specific indexing configuration. |
||
185 | * |
||
186 | * @param Site $site The site to initialize |
||
187 | * @param string $indexingConfigurationName name of a specific |
||
188 | * indexing configuration |
||
189 | * @return bool TRUE if the initialization was successful, FALSE otherwise |
||
190 | */ |
||
191 | 6 | protected function initializeIndexingConfiguration(Site $site, $indexingConfigurationName) |
|
192 | { |
||
193 | // clear queue |
||
194 | 6 | $this->deleteItemsBySite($site, $indexingConfigurationName); |
|
195 | |||
196 | 6 | $solrConfiguration = $site->getSolrConfiguration(); |
|
197 | |||
198 | 6 | $tableToIndex = $solrConfiguration->getIndexQueueTableNameOrFallbackToConfigurationName($indexingConfigurationName); |
|
199 | 6 | $initializerClass = $solrConfiguration->getIndexQueueInitializerClassByConfigurationName($indexingConfigurationName); |
|
200 | |||
201 | 6 | $initializer = GeneralUtility::makeInstance($initializerClass); |
|
202 | /** @var $initializer \ApacheSolrForTypo3\Solr\IndexQueue\Initializer\AbstractInitializer */ |
||
203 | 6 | $initializer->setSite($site); |
|
204 | 6 | $initializer->setType($tableToIndex); |
|
205 | 6 | $initializer->setIndexingConfigurationName($indexingConfigurationName); |
|
206 | |||
207 | 6 | $indexConfiguration = $solrConfiguration->getIndexQueueConfigurationByName($indexingConfigurationName); |
|
208 | 6 | $initializer->setIndexingConfiguration($indexConfiguration); |
|
209 | |||
210 | 6 | return $initializer->initialize(); |
|
211 | } |
||
212 | |||
213 | /** |
||
214 | * Marks an item as needing (re)indexing. |
||
215 | * |
||
216 | * Like with Solr itself, there's no add method, just a simple update method |
||
217 | * that handles the adds, too. |
||
218 | * |
||
219 | * The method creates or updates the index queue items for all related rootPageIds. |
||
220 | * |
||
221 | * @param string $itemType The item's type, usually a table name. |
||
222 | * @param string $itemUid The item's uid, usually an integer uid, could be a different value for non-database-record types. |
||
223 | * @param int $forcedChangeTime The change time for the item if set, otherwise value from getItemChangedTime() is used. |
||
224 | * @return int Number of updated/created items |
||
225 | */ |
||
226 | 61 | public function updateItem($itemType, $itemUid, $forcedChangeTime = 0) |
|
227 | { |
||
228 | 61 | $updateCount = $this->updateOrAddItemForAllRelatedRootPages($itemType, $itemUid, $forcedChangeTime); |
|
229 | 60 | $updateCount = $this->postProcessIndexQueueUpdateItem($itemType, $itemUid, $updateCount, $forcedChangeTime); |
|
230 | |||
231 | 60 | return $updateCount; |
|
232 | } |
||
233 | |||
234 | /** |
||
235 | * Updates or add's the item for all relevant root pages. |
||
236 | * |
||
237 | * @param string $itemType The item's type, usually a table name. |
||
238 | * @param string $itemUid The item's uid, usually an integer uid, could be a different value for non-database-record types. |
||
239 | * @param int $forcedChangeTime The change time for the item if set, otherwise value from getItemChangedTime() is used. |
||
240 | * @return int |
||
241 | */ |
||
242 | 59 | protected function updateOrAddItemForAllRelatedRootPages($itemType, $itemUid, $forcedChangeTime): int |
|
243 | { |
||
244 | 59 | $updateCount = 0; |
|
245 | 59 | $rootPageIds = $this->rootPageResolver->getResponsibleRootPageIds($itemType, $itemUid); |
|
246 | 58 | foreach ($rootPageIds as $rootPageId) { |
|
247 | 58 | $skipInvalidRootPage = $rootPageId === 0; |
|
248 | 58 | if ($skipInvalidRootPage) { |
|
249 | continue; |
||
250 | } |
||
251 | |||
252 | 58 | $solrConfiguration = Util::getSolrConfigurationFromPageId($rootPageId); |
|
253 | 58 | $indexingConfiguration = $this->recordService->getIndexingConfigurationName($itemType, $itemUid, $solrConfiguration); |
|
254 | 58 | $itemInQueueForRootPage = $this->containsItemWithRootPageId($itemType, $itemUid, $rootPageId); |
|
255 | 58 | if ($itemInQueueForRootPage) { |
|
256 | // update changed time if that item is in the queue already |
||
257 | 11 | $changedTime = ($forcedChangeTime > 0) ? $forcedChangeTime : $this->getItemChangedTime($itemType, $itemUid); |
|
258 | 11 | $updatedRows = $this->queueItemRepository->updateExistingItemByItemTypeAndItemUidAndRootPageId($itemType, $itemUid, $rootPageId, $changedTime, $indexingConfiguration); |
|
259 | } else { |
||
260 | // add the item since it's not in the queue yet |
||
261 | 52 | $updatedRows = $this->addNewItem($itemType, $itemUid, $indexingConfiguration, $rootPageId); |
|
262 | } |
||
263 | |||
264 | 58 | $updateCount += $updatedRows; |
|
265 | } |
||
266 | |||
267 | 58 | return $updateCount; |
|
268 | } |
||
269 | |||
270 | /** |
||
271 | * Executes the updateItem post processing hook. |
||
272 | * |
||
273 | * @param string $itemType |
||
274 | * @param int $itemUid |
||
275 | * @param int $updateCount |
||
276 | * @param int $forcedChangeTime |
||
277 | * @return int |
||
278 | */ |
||
279 | 60 | protected function postProcessIndexQueueUpdateItem($itemType, $itemUid, $updateCount, $forcedChangeTime = 0) |
|
280 | { |
||
281 | 60 | if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['postProcessIndexQueueUpdateItem'])) { |
|
282 | 59 | return $updateCount; |
|
283 | } |
||
284 | |||
285 | 1 | foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['postProcessIndexQueueUpdateItem'] as $classReference) { |
|
286 | 1 | $updateHandler = $this->getHookImplementation($classReference); |
|
287 | 1 | $updateCount = $updateHandler->postProcessIndexQueueUpdateItem($itemType, $itemUid, $updateCount, $forcedChangeTime); |
|
288 | } |
||
289 | |||
290 | 1 | return $updateCount; |
|
291 | } |
||
292 | |||
293 | /** |
||
294 | * @param string $classReference |
||
295 | * @return object |
||
296 | */ |
||
297 | protected function getHookImplementation($classReference) |
||
298 | { |
||
299 | return GeneralUtility::makeInstance($classReference); |
||
300 | } |
||
301 | |||
302 | /** |
||
303 | * Finds indexing errors for the current site |
||
304 | * |
||
305 | * @param Site $site |
||
306 | * @return array Error items for the current site's Index Queue |
||
307 | */ |
||
308 | public function getErrorsBySite(Site $site) |
||
309 | { |
||
310 | return $this->queueItemRepository->findErrorsBySite($site); |
||
311 | } |
||
312 | |||
313 | /** |
||
314 | * Resets all the errors for all index queue items. |
||
315 | * |
||
316 | * @return mixed |
||
317 | */ |
||
318 | public function resetAllErrors() |
||
319 | { |
||
320 | return $this->queueItemRepository->flushAllErrors(); |
||
321 | } |
||
322 | |||
323 | /** |
||
324 | * Adds an item to the index queue. |
||
325 | * |
||
326 | * Not meant for public use. |
||
327 | * |
||
328 | * @param string $itemType The item's type, usually a table name. |
||
329 | * @param string $itemUid The item's uid, usually an integer uid, could be a |
||
330 | * different value for non-database-record types. |
||
331 | * @param string $indexingConfiguration The item's indexing configuration to use. |
||
332 | * Optional, overwrites existing / determined configuration. |
||
333 | * @param $rootPageId |
||
334 | * @return int |
||
335 | */ |
||
336 | 52 | private function addNewItem($itemType, $itemUid, $indexingConfiguration, $rootPageId) |
|
337 | { |
||
338 | 52 | $additionalRecordFields = ''; |
|
339 | 52 | if ($itemType === 'pages') { |
|
340 | 30 | $additionalRecordFields = ', doktype, uid'; |
|
341 | } |
||
342 | |||
343 | 52 | $record = $this->getRecordCached($itemType, $itemUid, $additionalRecordFields); |
|
344 | |||
345 | 52 | if (empty($record) || ($itemType === 'pages' && !Util::isAllowedPageType($record, $indexingConfiguration))) { |
|
346 | 1 | return 0; |
|
347 | } |
||
348 | |||
349 | 51 | $changedTime = $this->getItemChangedTime($itemType, $itemUid); |
|
350 | |||
351 | 51 | return $this->queueItemRepository->add($itemType, $itemUid, $rootPageId, $changedTime, $indexingConfiguration); |
|
352 | } |
||
353 | |||
354 | /** |
||
355 | * Get record to be added in addNewItem |
||
356 | * |
||
357 | * @param string $itemType The item's type, usually a table name. |
||
358 | * @param string $itemUid The item's uid, usually an integer uid, could be a |
||
359 | * different value for non-database-record types. |
||
360 | * @param string $additionalRecordFields for sql-query |
||
361 | * |
||
362 | * @return array|NULL |
||
363 | */ |
||
364 | 52 | protected function getRecordCached($itemType, $itemUid, $additionalRecordFields) |
|
365 | { |
||
366 | 52 | $cache = GeneralUtility::makeInstance(TwoLevelCache::class, 'cache_runtime'); |
|
367 | 52 | $cacheId = md5('Queue' . ':' . 'getRecordCached' . ':' . $itemType . ':' . $itemUid . ':' . 'pid' . $additionalRecordFields); |
|
368 | |||
369 | 52 | $record = $cache->get($cacheId); |
|
370 | 52 | if (empty($record)) { |
|
371 | 52 | $record = BackendUtility::getRecord($itemType, $itemUid, 'pid' . $additionalRecordFields); |
|
372 | 52 | $cache->set($cacheId, $record); |
|
373 | } |
||
374 | |||
375 | 52 | 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 | * @param string $itemType The item's table name. |
||
388 | * @param string $itemUid The item's uid, usually an integer uid, could be a |
||
389 | * different value for non-database-record types. |
||
390 | * @return int Timestamp of the item's changed time or future start time |
||
391 | */ |
||
392 | 57 | protected function getItemChangedTime($itemType, $itemUid) |
|
393 | { |
||
394 | 57 | $itemTypeHasStartTimeColumn = false; |
|
395 | 57 | $changedTimeColumns = $GLOBALS['TCA'][$itemType]['ctrl']['tstamp']; |
|
396 | 57 | $startTime = 0; |
|
397 | 57 | $pageChangedTime = 0; |
|
398 | |||
399 | 57 | if (!empty($GLOBALS['TCA'][$itemType]['ctrl']['enablecolumns']['starttime'])) { |
|
400 | 57 | $itemTypeHasStartTimeColumn = true; |
|
401 | 57 | $changedTimeColumns .= ', ' . $GLOBALS['TCA'][$itemType]['ctrl']['enablecolumns']['starttime']; |
|
402 | } |
||
403 | 57 | if ($itemType === 'pages') { |
|
404 | // does not carry time information directly, but needed to support |
||
405 | // canonical pages |
||
406 | 35 | $changedTimeColumns .= ', content_from_pid'; |
|
407 | } |
||
408 | |||
409 | 57 | $record = BackendUtility::getRecord($itemType, $itemUid, $changedTimeColumns); |
|
410 | 57 | $itemChangedTime = $record[$GLOBALS['TCA'][$itemType]['ctrl']['tstamp']]; |
|
411 | |||
412 | 57 | if ($itemTypeHasStartTimeColumn) { |
|
413 | 57 | $startTime = $record[$GLOBALS['TCA'][$itemType]['ctrl']['enablecolumns']['starttime']]; |
|
414 | } |
||
415 | |||
416 | 57 | if ($itemType === 'pages') { |
|
417 | 35 | $record['uid'] = $itemUid; |
|
418 | // overrule the page's last changed time with the most recent |
||
419 | //content element change |
||
420 | 35 | $pageChangedTime = $this->getPageItemChangedTime($record); |
|
421 | } |
||
422 | |||
423 | 57 | $localizationsChangedTime = $this->queueItemRepository->getLocalizableItemChangedTime($itemType, (int)$itemUid); |
|
424 | |||
425 | // if start time exists and start time is higher than last changed timestamp |
||
426 | // then set changed to the future start time to make the item |
||
427 | // indexed at a later time |
||
428 | 57 | $changedTime = max( |
|
429 | 57 | $itemChangedTime, |
|
430 | 57 | $pageChangedTime, |
|
431 | 57 | $localizationsChangedTime, |
|
432 | 57 | $startTime |
|
433 | ); |
||
434 | |||
435 | 57 | return $changedTime; |
|
436 | } |
||
437 | |||
438 | /** |
||
439 | * Gets the most recent changed time of a page's content elements |
||
440 | * |
||
441 | * @param array $page Partial page record |
||
442 | * @return int Timestamp of the most recent content element change |
||
443 | */ |
||
444 | 35 | protected function getPageItemChangedTime(array $page) |
|
445 | { |
||
446 | 35 | if (!empty($page['content_from_pid'])) { |
|
447 | // canonical page, get the original page's last changed time |
||
448 | return $this->queueItemRepository->getPageItemChangedTimeByPageUid((int)$page['content_from_pid']); |
||
449 | } |
||
450 | 35 | return $this->queueItemRepository->getPageItemChangedTimeByPageUid((int)$page['uid']); |
|
451 | } |
||
452 | |||
453 | /** |
||
454 | * Checks whether the Index Queue contains a specific item. |
||
455 | * |
||
456 | * @param string $itemType The item's type, usually a table name. |
||
457 | * @param string $itemUid The item's uid, usually an integer uid, could be a |
||
458 | * different value for non-database-record types. |
||
459 | * @return bool TRUE if the item is found in the queue, FALSE otherwise |
||
460 | */ |
||
461 | 6 | public function containsItem($itemType, $itemUid) |
|
462 | { |
||
463 | 6 | return $this->queueItemRepository->containsItem($itemType, (int)$itemUid); |
|
464 | } |
||
465 | |||
466 | /** |
||
467 | * Checks whether the Index Queue contains a specific item. |
||
468 | * |
||
469 | * @param string $itemType The item's type, usually a table name. |
||
470 | * @param string $itemUid The item's uid, usually an integer uid, could be a |
||
471 | * different value for non-database-record types. |
||
472 | * @param integer $rootPageId |
||
473 | * @return bool TRUE if the item is found in the queue, FALSE otherwise |
||
474 | */ |
||
475 | 58 | public function containsItemWithRootPageId($itemType, $itemUid, $rootPageId) |
|
476 | { |
||
477 | 58 | return $this->queueItemRepository->containsItemWithRootPageId($itemType, (int)$itemUid, (int)$rootPageId); |
|
478 | } |
||
479 | |||
480 | /** |
||
481 | * Checks whether the Index Queue contains a specific item that has been |
||
482 | * marked as indexed. |
||
483 | * |
||
484 | * @param string $itemType The item's type, usually a table name. |
||
485 | * @param string $itemUid The item's uid, usually an integer uid, could be a |
||
486 | * different value for non-database-record types. |
||
487 | * @return bool TRUE if the item is found in the queue and marked as |
||
488 | * indexed, FALSE otherwise |
||
489 | */ |
||
490 | 3 | public function containsIndexedItem($itemType, $itemUid) |
|
491 | { |
||
492 | 3 | return $this->queueItemRepository->containsIndexedItem($itemType, (int)$itemUid); |
|
493 | } |
||
494 | |||
495 | /** |
||
496 | * Removes an item from the Index Queue. |
||
497 | * |
||
498 | * @param string $itemType The type of the item to remove, usually a table name. |
||
499 | * @param int $itemUid The uid of the item to remove |
||
500 | */ |
||
501 | 29 | public function deleteItem($itemType, $itemUid) |
|
502 | { |
||
503 | 29 | $this->queueItemRepository->deleteItem($itemType, (int)$itemUid); |
|
504 | 29 | } |
|
505 | |||
506 | /** |
||
507 | * Removes all items of a certain type from the Index Queue. |
||
508 | * |
||
509 | * @param string $itemType The type of items to remove, usually a table name. |
||
510 | */ |
||
511 | 1 | public function deleteItemsByType($itemType) |
|
512 | { |
||
513 | 1 | $this->queueItemRepository->deleteItemsByType($itemType); |
|
514 | 1 | } |
|
515 | |||
516 | /** |
||
517 | * Removes all items of a certain site from the Index Queue. Accepts an |
||
518 | * optional parameter to limit the deleted items by indexing configuration. |
||
519 | * |
||
520 | * @param Site $site The site to remove items for. |
||
521 | * @param string $indexingConfigurationName Name of a specific indexing |
||
522 | * configuration |
||
523 | */ |
||
524 | 6 | public function deleteItemsBySite(Site $site, $indexingConfigurationName = '') |
|
525 | { |
||
526 | 6 | $this->queueItemRepository->deleteItemsBySite($site, $indexingConfigurationName); |
|
527 | 6 | } |
|
528 | |||
529 | /** |
||
530 | * Removes all items from the Index Queue. |
||
531 | * |
||
532 | */ |
||
533 | 1 | public function deleteAllItems() |
|
534 | { |
||
535 | 1 | $this->queueItemRepository->deleteAllItems(); |
|
536 | 1 | } |
|
537 | |||
538 | /** |
||
539 | * Gets a single Index Queue item by its uid. |
||
540 | * |
||
541 | * @param int $itemId Index Queue item uid |
||
542 | * @return Item The request Index Queue item or NULL if no item with $itemId was found |
||
543 | */ |
||
544 | 23 | public function getItem($itemId) |
|
545 | { |
||
546 | 23 | return $this->queueItemRepository->findItemByUid($itemId); |
|
547 | } |
||
548 | |||
549 | /** |
||
550 | * Gets Index Queue items by type and uid. |
||
551 | * |
||
552 | * @param string $itemType item type, usually the table name |
||
553 | * @param int $itemUid item uid |
||
554 | * @return Item[] An array of items matching $itemType and $itemUid |
||
555 | */ |
||
556 | 33 | public function getItems($itemType, $itemUid) |
|
557 | { |
||
558 | 33 | return $this->queueItemRepository->findItemsByItemTypeAndItemUid($itemType, (int)$itemUid); |
|
559 | } |
||
560 | |||
561 | /** |
||
562 | * Returns all items in the queue. |
||
563 | * |
||
564 | * @return Item[] An array of items |
||
565 | */ |
||
566 | public function getAllItems() |
||
567 | { |
||
568 | return $this->queueItemRepository->findAll(); |
||
569 | } |
||
570 | |||
571 | /** |
||
572 | * Returns the number of items for all queues. |
||
573 | * |
||
574 | * @return int |
||
575 | */ |
||
576 | 69 | public function getAllItemsCount() |
|
577 | { |
||
578 | 69 | return $this->queueItemRepository->count(); |
|
579 | } |
||
580 | |||
581 | /** |
||
582 | * Extracts the number of pending, indexed and erroneous items from the |
||
583 | * Index Queue. |
||
584 | * |
||
585 | * @param Site $site |
||
586 | * @param string $indexingConfigurationName |
||
587 | * |
||
588 | * @return QueueStatistic |
||
589 | */ |
||
590 | 6 | public function getStatisticsBySite(Site $site, $indexingConfigurationName = '') |
|
591 | { |
||
592 | 6 | return $this->queueStatisticsRepository->findOneByRootPidAndOptionalIndexingConfigurationName($site->getRootPageId(), $indexingConfigurationName); |
|
593 | } |
||
594 | |||
595 | /** |
||
596 | * Gets $limit number of items to index for a particular $site. |
||
597 | * |
||
598 | * @param Site $site TYPO3 site |
||
599 | * @param int $limit Number of items to get from the queue |
||
600 | * @return Item[] Items to index to the given solr server |
||
601 | */ |
||
602 | 7 | public function getItemsToIndex(Site $site, $limit = 50) |
|
603 | { |
||
604 | 7 | return $this->queueItemRepository->findItemsToIndex($site, $limit); |
|
605 | } |
||
606 | |||
607 | /** |
||
608 | * Marks an item as failed and causes the indexer to skip the item in the |
||
609 | * next run. |
||
610 | * |
||
611 | * @param int|Item $item Either the item's Index Queue uid or the complete item |
||
612 | * @param string $errorMessage Error message |
||
613 | */ |
||
614 | 6 | public function markItemAsFailed($item, $errorMessage = '') |
|
615 | { |
||
616 | 6 | $this->queueItemRepository->markItemAsFailed($item, $errorMessage); |
|
617 | 6 | } |
|
618 | |||
619 | /** |
||
620 | * Sets the timestamp of when an item last has been indexed. |
||
621 | * |
||
622 | * @param Item $item |
||
623 | */ |
||
624 | 6 | public function updateIndexTimeByItem(Item $item) |
|
625 | { |
||
626 | 6 | $this->queueItemRepository->updateIndexTimeByItem($item); |
|
627 | 6 | } |
|
628 | } |
||
629 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths