/** * Works through the indexing queue and indexes the queued items into Solr. * * @return boolean Returns TRUE on success, FALSE if no items were indexed or none were found. */ public function execute() { $executionSucceeded = false; $this->configuration = Util::getSolrConfigurationFromPageId($this->site->getRootPageId()); $this->indexItems(); $executionSucceeded = true; return $executionSucceeded; }
/** * Works through the indexing queue and indexes the queued items into Solr. * * @return boolean Returns TRUE on success, FALSE if no items were indexed or none were found. */ public function execute() { $executionSucceeded = FALSE; $this->configuration = Util::getSolrConfigurationFromPageId($this->site->getRootPageId()); $this->indexItems(); $this->cleanIndex(); $executionSucceeded = TRUE; return $executionSucceeded; }
/** * Gets an array of tables configured for indexing by the Index Queue. The * record monitor must watch these tables for manipulation. * * @param integer $pageId The page id for which we need to retrieve the configuration for * @return array Array of table names to be watched by the record monitor. */ protected function getMonitoredTables($pageId) { $monitoredTables = array(); // FIXME!! $pageId might be outside of a site root and thus might not know about solr configuration // -> leads to record not being queued for reindexing $solrConfiguration = Util::getSolrConfigurationFromPageId($pageId); $indexingConfigurations = $solrConfiguration->getEnabledIndexQueueConfigurationNames(); foreach ($indexingConfigurations as $indexingConfigurationName) { $monitoredTable = $this->solrConfiguration->getIndexQueueTableNameOrFallbackToConfigurationName($indexingConfigurationName); $monitoredTables[] = $monitoredTable; if ($monitoredTable == 'pages') { // when monitoring pages, also monitor creation of translations $monitoredTables[] = 'pages_language_overlay'; } } return array_unique($monitoredTables); }
/** * Gets an array of tables configured for indexing by the Index Queue. The * record monitor must watch these tables for manipulation. * * @param integer $pageId The page id for which we need to retrieve the configuration for * @return array Array of table names to be watched by the record monitor. */ protected function getMonitoredTables($pageId) { $monitoredTables = array(); // FIXME!! $pageId might be outside of a site root and thus might not know about solr configuration // -> leads to record not being queued for reindexing $solrConfiguration = Util::getSolrConfigurationFromPageId($pageId); $indexingConfigurations = GeneralUtility::makeInstance('ApacheSolrForTypo3\\Solr\\IndexQueue\\Queue')->getTableIndexingConfigurations($solrConfiguration); foreach ($indexingConfigurations as $indexingConfigurationName) { $monitoredTable = $indexingConfigurationName; if (!empty($solrConfiguration['index.']['queue.'][$indexingConfigurationName . '.']['table'])) { // table has been set explicitly. Allows to index the same table with different configurations $monitoredTable = $solrConfiguration['index.']['queue.'][$indexingConfigurationName . '.']['table']; } $monitoredTables[] = $monitoredTable; if ($monitoredTable == 'pages') { // when monitoring pages, also monitor creation of translations $monitoredTables[] = 'pages_language_overlay'; } } return array_unique($monitoredTables); }
/** * Gets the site's Solr TypoScript configuration (plugin.tx_solr.*) * * @return array The Solr TypoScript configuration */ public function getSolrConfiguration() { return Util::getSolrConfigurationFromPageId($this->rootPage['uid']); }
/** * Enables logging dependent on the configuration of the item's site * * @param Item $item An item being indexed * @return void */ protected function setLogging(Item $item) { // reset $this->loggingEnabled = FALSE; $solrConfiguration = Util::getSolrConfigurationFromPageId($item->getRootPageUid()); if (!empty($solrConfiguration['logging.']['indexing']) || !empty($solrConfiguration['logging.']['indexing.']['queue']) || !empty($solrConfiguration['logging.']['indexing.']['queue.'][$item->getIndexingConfigurationName()])) { $this->loggingEnabled = TRUE; } }
/** * Adds an item to the index queue. * * Not meant for public use. * * @param string $itemType The item's type, usually a table name. * @param string $itemUid The item's uid, usually an integer uid, could be a * different value for non-database-record types. * @param string $indexingConfiguration The item's indexing configuration to use. * Optional, overwrites existing / determined configuration. * @return void */ private function addItem($itemType, $itemUid, $indexingConfiguration) { $additionalRecordFields = ''; if ($itemType == 'pages') { $additionalRecordFields = ', doktype, uid'; } $record = BackendUtility::getRecord($itemType, $itemUid, 'pid' . $additionalRecordFields); if (empty($record) || $itemType == 'pages' && !Util::isAllowedPageType($record)) { return; } if ($itemType == 'pages') { $rootPageId = Util::getRootPageId($itemUid); } else { $rootPageId = Util::getRootPageId($record['pid']); } if (Util::isRootPage($rootPageId)) { $item = array('root' => $rootPageId, 'item_type' => $itemType, 'item_uid' => $itemUid, 'changed' => $this->getItemChangedTime($itemType, $itemUid)); if (!empty($indexingConfiguration)) { $indexingConfigurationList = array($indexingConfiguration); } else { $indexingConfigurationList = $this->getIndexingConfigurationsByItem($itemType, $itemUid, $rootPageId); } $solrConfiguration = Util::getSolrConfigurationFromPageId($rootPageId); // make a backup of the current item $baseItem = $item; foreach ($indexingConfigurationList as $indexingConfigurationCurrent) { $item = $baseItem; $item['indexing_configuration'] = $indexingConfigurationCurrent; $addItemToQueue = TRUE; // Ensure additionalWhereClause is applied. if (!empty($solrConfiguration['index.']['queue.'][$item['indexing_configuration'] . '.']['additionalWhereClause'])) { $indexingConfigurationCheckRecord = BackendUtility::getRecord($itemType, $itemUid, 'pid' . $additionalRecordFields, ' AND ' . $solrConfiguration['index.']['queue.'][$item['indexing_configuration'] . '.']['additionalWhereClause']); if (empty($indexingConfigurationCheckRecord)) { // item does not match the indexing configuration's additionalWhereClause $addItemToQueue = FALSE; } } if ($addItemToQueue) { $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_solr_indexqueue_item', $item); } } } }
/** * Builds a map of indexing configuration names to tables to to index. * * @return array Indexing configuration to database table map */ protected function getIndexQueueConfigurationTableMap() { $indexingTableMap = array(); $solrConfiguration = Util::getSolrConfigurationFromPageId($this->site->getRootPageId()); foreach ($solrConfiguration['index.']['queue.'] as $name => $configuration) { if (is_array($configuration)) { $name = substr($name, 0, -1); if ($solrConfiguration['index.']['queue.'][$name]) { $table = $name; if ($solrConfiguration['index.']['queue.'][$name . '.']['table']) { $table = $solrConfiguration['index.']['queue.'][$name . '.']['table']; } $indexingTableMap[$name] = $table; } } } return $indexingTableMap; }
/** * Enables logging dependent on the configuration of the item's site * * @param Item $item An item being indexed * @return void */ protected function setLogging(Item $item) { $solrConfiguration = Util::getSolrConfigurationFromPageId($item->getRootPageUid()); $this->loggingEnabled = $solrConfiguration->getLoggingIndexingQueueOperationsByConfigurationNameWithFallBack($item->getIndexingConfigurationName()); }