/** * Hooks into TCE Main and watches all record updates. If a change is * detected that would remove the record from the website, we try to find * related documents and remove them from the index. * * @param string $status Status of the current operation, 'new' or 'update' * @param string $table The table the record belongs to * @param mixed $uid The record's uid, [integer] or [string] (like 'NEW...') * @param array $fields The record's data, not used * @param t3lib_TCEmain $tceMain TYPO3 Core Engine parent object, not used */ public function processDatamap_afterDatabaseOperations($status, $table, $uid, array $fields, t3lib_TCEmain $tceMain) { if ($status == 'new') { // a newly created record, skip return; } if (Tx_Solr_Util::isDraftRecord($table, $uid)) { // skip workspaces: collect garbage only for LIVE workspace return; } $garbageCollectionRelevantFields = $this->getVisibilityAffectingFieldsByTable($table); $record = t3lib_BEfunc::getRecord($table, $uid, $garbageCollectionRelevantFields, '', FALSE); $record = $this->normalizeFrontendGroupField($table, $record); if ($this->isHidden($table, $record) || $this->isStartTimeInFuture($table, $record) && $this->isMarkedAsIndexed($table, $record) || $this->hasFrontendGroupsRemoved($table, $record) || $table == 'pages' && $this->isPageExcludedFromSearch($record) || $table == 'pages' && !$this->isIndexablePageType($record)) { $this->collectGarbage($table, $uid); } }
/** * Hooks into TCE Main and watches all record creations and updates. If it * detects that the new/updated record belongs to a table configured for * indexing through Solr, we add the record to the index queue. * * @param string $status Status of the current operation, 'new' or 'update' * @param string $table The table the record belongs to * @param mixed $uid The record's uid, [integer] or [string] (like 'NEW...') * @param array $fields The record's data * @param t3lib_TCEmain $tceMain TYPO3 Core Engine parent object * @return void */ public function processDatamap_afterDatabaseOperations($status, $table, $uid, array $fields, t3lib_TCEmain $tceMain) { $recordTable = $table; $recordUid = $uid; $recordPageId = 0; if ($status == 'new') { $recordUid = $tceMain->substNEWwithIDs[$recordUid]; } if (Tx_Solr_Util::isDraftRecord($table, $recordUid)) { // skip workspaces: index only LIVE workspace return; } if ($status == 'update' && !isset($fields['pid'])) { $recordPageId = $tceMain->getPID($recordTable, $recordUid); } else { $recordPageId = $fields['pid']; } // when a content element changes we need to updated the page instead if ($recordTable == 'tt_content') { $recordTable = 'pages'; $recordUid = $recordPageId; } $this->solrConfiguration = Tx_Solr_Util::getSolrConfigurationFromPageId($recordPageId); $monitoredTables = $this->getMonitoredTables($recordPageId); if (in_array($recordTable, $monitoredTables, TRUE)) { $record = $this->getRecord($recordTable, $recordUid); if (!empty($record)) { // only update/insert the item if we actually found a record if ($this->isLocalizedRecord($recordTable, $record)) { // if it's a localization overlay, update the original record instead $recordUid = $record[$GLOBALS['TCA'][$recordTable]['ctrl']['transOrigPointerField']]; if ($recordTable == 'pages_language_overlay') { $recordTable = 'pages'; } } $this->indexQueue->updateItem($recordTable, $recordUid); if ($recordTable == 'pages') { $this->updateCanonicalPages($recordUid); $this->updateMountPages($recordUid); } } else { // TODO move this part to the garbage collector // check if the item should be removed from the index because it no longer matches the conditions if ($this->indexQueue->containsItem($recordTable, $recordUid)) { $this->removeFromIndexAndQueue($recordTable, $recordUid); } } } }