diff --git a/Classes/GarbageCollector.php b/Classes/GarbageCollector.php index a9cc77dc2d..d7b2480996 100644 --- a/Classes/GarbageCollector.php +++ b/Classes/GarbageCollector.php @@ -189,6 +189,10 @@ public function processDatamap_afterDatabaseOperations($status, $table, $uid, ar return; } + if (Util::skipHooksForRecord($table, $uid, $fields['pid'] ?? null)) { + return; + } + $updatedRecord = $this->getGarbageHandler()->getRecordWithFieldRelevantForGarbageCollection($table, $uid); if (empty($updatedRecord)) { return; diff --git a/Classes/IndexQueue/RecordMonitor.php b/Classes/IndexQueue/RecordMonitor.php index 2d0b9c978d..b9955691b5 100644 --- a/Classes/IndexQueue/RecordMonitor.php +++ b/Classes/IndexQueue/RecordMonitor.php @@ -148,6 +148,10 @@ public function processDatamap_afterDatabaseOperations( return; } + if (Util::skipHooksForRecord($table, (int)$recordUid, $recordPid)) { + return; + } + if ($status === 'new' && !MathUtility::canBeInterpretedAsInteger($recordUid)) { if (isset($tceMain->substNEWwithIDs[$recordUid])) { $recordUid = $tceMain->substNEWwithIDs[$recordUid]; diff --git a/Classes/Util.php b/Classes/Util.php index d003f9a00f..c8ec9ef41e 100644 --- a/Classes/Util.php +++ b/Classes/Util.php @@ -25,8 +25,11 @@ use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Context\Context; use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException; +use TYPO3\CMS\Core\Exception\SiteNotFoundException; +use TYPO3\CMS\Core\Site\SiteFinder; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\Utility\MathUtility; /** * Utility class for tx_solr @@ -134,6 +137,34 @@ public static function isDraftRecord( return $isWorkspaceRecord; } + public static function skipHooksForRecord( + string $table, + int $uid, + ?int $pid + ): bool { + if (is_null($pid) && MathUtility::canBeInterpretedAsInteger($uid)) { + $recordInfo = BackendUtility::getRecord($table, $uid, 'pid'); + if (!is_null($recordInfo)) { + $pid = $recordInfo['pid'] ?? null; + } + } + + if (!is_null($pid)) { + /** @var SiteFinder $siteFinder */ + $siteFinder = GeneralUtility::makeInstance(SiteFinder::class); + try { + $site = $siteFinder->getSiteByPageId($pid); + } catch (SiteNotFoundException) { + return false; + } + if ((bool)($site->getConfiguration()['solr_skip_hooks'] ?? false)) { + return true; + } + } + + return false; + } + /** * This function can be used to check if one of the strings in needles is * contained in the haystack. diff --git a/Configuration/SiteConfiguration/Overrides/sites.php b/Configuration/SiteConfiguration/Overrides/sites.php index 49f83b2283..e3cfd68008 100644 --- a/Configuration/SiteConfiguration/Overrides/sites.php +++ b/Configuration/SiteConfiguration/Overrides/sites.php @@ -87,6 +87,23 @@ 'displayCond' => 'FIELD:solr_enabled_read:=:1', ]; +$GLOBALS['SiteConfiguration']['site']['columns']['solr_skip_hooks'] = [ + 'label' => 'Disable TYPO3 hooks for this site', + 'config' => [ + 'type' => 'check', + 'renderType' => 'checkboxToggle', + 'default' => 0, + 'items' => [ + [ + 'label' => '', + 'labelChecked' => '', + 'labelUnchecked' => '', + ], + ], + ], + 'displayCond' => 'FIELD:solr_enabled_read:=:1', +]; + // write TCA $GLOBALS['SiteConfiguration']['site']['columns']['solr_scheme_write'] = $GLOBALS['SiteConfiguration']['site']['columns']['solr_scheme_read']; $GLOBALS['SiteConfiguration']['site']['columns']['solr_scheme_write']['displayCond'] = 'FIELD:solr_use_write_connection:=:1'; @@ -106,7 +123,7 @@ $GLOBALS['SiteConfiguration']['site']['palettes']['solr_read']['showitem'] = 'solr_scheme_read, solr_port_read, --linebreak--, solr_host_read, solr_path_read'; $GLOBALS['SiteConfiguration']['site']['palettes']['solr_write']['showitem'] = 'solr_scheme_write, solr_port_write, --linebreak--, solr_host_write, solr_path_write'; -$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] .= ',--div--;Solr,solr_enabled_read,--palette--;;solr_read, solr_use_write_connection,--palette--;;solr_write'; +$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] .= ',--div--;Solr,solr_enabled_read,--palette--;;solr_read, solr_use_write_connection,--palette--;;solr_write,solr_skip_hooks'; /** * Language specific core configuration