Skip to content

Commit

Permalink
[BUGFIX] Custom doktype is deleted from solr after saving with custom…
Browse files Browse the repository at this point in the history
… queue configuration

When a page is saved, the GarbageHandler will check in all queue configuration if the doktype is allowed, not only in "pages" queue configuration.

Fixes: #3450
  • Loading branch information
b3nkai authored and dkd-friedrich committed Jan 23, 2023
1 parent 8157efd commit ed3ce05
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Classes/FrontendEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function getConfigurationFromPageId(int $pageId, ?string $path = '', ?int
* @return bool
* @throws DBALDriverException
*/
public function isAllowedPageType(array $pageRecord, ?string $configurationName = 'pages'): bool
public function isAllowedPageType(array $pageRecord, ?string $configurationName = null): bool
{
// $pageRecord could come from DataHandler and with all columns. So we want to fetch it again.
$pageRecord = BackendUtility::getRecord('pages', $pageRecord['uid']);
Expand All @@ -79,7 +79,13 @@ public function isAllowedPageType(array $pageRecord, ?string $configurationName
return false;
}
$configuration = $this->getConfigurationFromPageId($rootPageRecordUid, '', $tsfe->getLanguage()->getLanguageId());
$allowedPageTypes = $configuration->getIndexQueueAllowedPageTypesArrayByConfigurationName($configurationName);
if ($configurationName !== null) {
$allowedPageTypes = $configuration->getIndexQueueAllowedPageTypesArrayByConfigurationName($configurationName);
} else {
// If the $configurationName is not provided,
// we will check if one of the configurations allow the pagetype to be indexed
$allowedPageTypes = $configuration->getAllIndexQueueAllowedPageTypesArray();
}
return in_array($pageRecord['doktype'], $allowedPageTypes);
}

Expand Down
28 changes: 28 additions & 0 deletions Classes/System/Configuration/TypoScriptConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,34 @@ public function getIndexQueueAllowedPageTypesArrayByConfigurationName(string $co
return GeneralUtility::trimExplode(',', $result);
}

/**
* Returns an array of allowedPageTypes declared in all queue configurations.
*
* plugin.tx_solr.index.queue.*.allowedPageTypes
*
* @return array
*/
public function getAllIndexQueueAllowedPageTypesArray(): array
{
$configuration = $this->configurationAccess->get('plugin.tx_solr.index.queue.');

if (!is_array($configuration)) {
return [];
}

$allowedPageTypes = [];
foreach ($configuration as $queueName => $queueConfiguration) {
if (is_array($queueConfiguration)
&& !empty($queueConfiguration['allowedPageTypes'])
&& $this->getIndexQueueConfigurationIsEnabled(rtrim($queueName, '.'))
) {
$allowedPageTypes = array_merge($allowedPageTypes, GeneralUtility::trimExplode(',', $queueConfiguration['allowedPageTypes'], true));
}
}

return array_unique($allowedPageTypes);
}

/**
* Returns the configured excludeContentByClass patterns as array.
*
Expand Down

0 comments on commit ed3ce05

Please sign in to comment.