Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Classes/GarbageCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions Classes/IndexQueue/RecordMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
31 changes: 31 additions & 0 deletions Classes/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
19 changes: 18 additions & 1 deletion Configuration/SiteConfiguration/Overrides/sites.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down
Loading