/** * 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. * @see typo3/sysext/scheduler/tx_scheduler_Task#execute() */ public function execute() { $executionSucceeded = FALSE; $this->configuration = Tx_Solr_Util::getSolrConfigurationFromPageId($this->site->getRootPageId()); $this->indexItems(); $this->cleanIndex(); $executionSucceeded = TRUE; return $executionSucceeded; }
/** * Enables logging dependent on the configuration of the item's site * * @param Tx_Solr_IndexQueue_Item $item An item being indexed * @return void */ protected function setLogging(Tx_Solr_IndexQueue_Item $item) { // reset $this->loggingEnabled = FALSE; $solrConfiguration = Tx_Solr_Util::getSolrConfigurationFromPageId($item->getRootPageUid()); if (!empty($solrConfiguration['logging.']['indexing']) || !empty($solrConfiguration['logging.']['indexing.']['queue']) || !empty($solrConfiguration['logging.']['indexing.']['queue.'][$item->getIndexingConfigurationName()])) { $this->loggingEnabled = TRUE; } }
/** * 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 = \Tx_Solr_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; }
/** * Gets the indexing configurations to use for an item. * Multiple configurations for a certain item type (table) might be available. * * @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 integer $rootPageId The configuration's page tree's root page id. * Optional, not needed for all types. * @return array<string> The indexing configurations names to use when indexing */ protected function getIndexingConfigurationsByItem($itemType, $itemUid, $rootPageId = NULL) { $possibleIndexingConfigurationNames = array(); if (!is_null($rootPageId)) { // get configuration for the root's branch $solrConfiguration = Tx_Solr_Util::getSolrConfigurationFromPageId($rootPageId); // which configurations are there? $indexingConfigurations = $this->getTableIndexingConfigurations($solrConfiguration); foreach ($indexingConfigurations as $indexingConfigurationName) { if ($indexingConfigurationName == $itemType || !empty($solrConfiguration['index.']['queue.'][$indexingConfigurationName . '.']['table']) && $solrConfiguration['index.']['queue.'][$indexingConfigurationName . '.']['table'] == $itemType) { $possibleIndexingConfigurationNames[] = $indexingConfigurationName; } } } return $possibleIndexingConfigurationNames; }
/** * Gets the site's Solr TypoScript configuration (plugin.tx_solr.*) * * @return array The Solr TypoScript configuration */ public function getSolrConfiguration() { return Tx_Solr_Util::getSolrConfigurationFromPageId($this->rootPage['uid']); }
/** * Gets an array of tables configured for indexing by the Index Queue. The * record monitor must watch these tables for manipulation. * * @param integer 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 = Tx_Solr_Util::getSolrConfigurationFromPageId($pageId); $indexingConfigurations = t3lib_div::makeInstance('Tx_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); }