/** * Initializes Mount Pages to be indexed through the Index Queue. The Mount * Pages are searched and their mounted virtual sub-trees are then resolved * and added to the Index Queue as if they were actually present below the * Mount Page. * * @return boolean TRUE if initialization of the Mount Pages was successful, FALSE otherwise */ protected function initializeMountPages() { $mountPagesInitialized = false; $mountPages = $this->findMountPages(); if (empty($mountPages)) { $mountPagesInitialized = true; return $mountPagesInitialized; } foreach ($mountPages as $mountPage) { if (!$this->validateMountPage($mountPage)) { continue; } $mountedPages = $this->resolveMountPageTree($mountPage['mountPageSource']); // handling mount_pid_ol behavior if ($mountPage['mountPageOverlayed']) { // the page shows the mounted page's content $mountedPages[] = $mountPage['mountPageSource']; } else { // Add page like a regular page, as only the sub tree is // mounted. The page itself has its own content. GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\IndexQueue\\Queue')->updateItem($this->type, $mountPage['uid'], $this->indexingConfigurationName); } // This can happen when the mount point does not show the content of the // mounted page and the mounted page does not have any subpages. if (empty($mountedPages)) { continue; } DatabaseUtility::transactionStart(); try { $this->addMountedPagesToIndexQueue($mountedPages, $mountPage); $this->addIndexQueueItemIndexingProperties($mountPage, $mountedPages); DatabaseUtility::transactionCommit(); $mountPagesInitialized = true; } catch (\Exception $e) { DatabaseUtility::transactionRollback(); GeneralUtility::devLog('Index Queue initialization failed for mount pages', 'solr', 3, array($e->__toString())); break; } } return $mountPagesInitialized; }
/** * Removes all items of a certain site from the Index Queue. Accepts an * optional parameter to limit the deleted items by indexing configuration. * * @param Site $site The site to remove items for. * @param string $indexingConfigurationName Name of a specific indexing * configuration */ public function deleteItemsBySite(Site $site, $indexingConfigurationName = '') { $rootPageConstraint = 'tx_solr_indexqueue_item.root = ' . $site->getRootPageId(); $indexingConfigurationConstraint = ''; if (!empty($indexingConfigurationName)) { $indexingConfigurationConstraint = ' AND tx_solr_indexqueue_item.indexing_configuration = \'' . $indexingConfigurationName . '\''; } DatabaseUtility::transactionStart(); try { // reset Index Queue $result = $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_solr_indexqueue_item', $rootPageConstraint . $indexingConfigurationConstraint); if (!$result) { throw new \RuntimeException('Failed to reset Index Queue for site ' . $site->getLabel(), 1412986560); } // reset Index Queue Properties $indexQueuePropertyResetQuery = ' DELETE tx_solr_indexqueue_indexing_property.* FROM tx_solr_indexqueue_indexing_property INNER JOIN tx_solr_indexqueue_item ON tx_solr_indexqueue_item.uid = tx_solr_indexqueue_indexing_property.item_id AND ' . $rootPageConstraint . $indexingConfigurationConstraint; $result = $GLOBALS['TYPO3_DB']->sql_query($indexQueuePropertyResetQuery); if (!$result) { throw new \RuntimeException('Failed to reset Index Queue properties for site ' . $site->getLabel(), 1412986604); } DatabaseUtility::transactionCommit(); } catch (\RuntimeException $e) { DatabaseUtility::transactionRollback(); } }