Skip to content

Commit

Permalink
[FIX] scheduler task "Optimize index of a site" is not functional
Browse files Browse the repository at this point in the history
Fixes multiple issues within "Optimize index of a site" component.

Relates: #4102
  • Loading branch information
dkd-kaehm committed Jul 10, 2024
1 parent fef3dde commit c2db99c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
36 changes: 26 additions & 10 deletions Classes/Backend/CoreSelectorField.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

namespace ApacheSolrForTypo3\Solr\Backend;

use ApacheSolrForTypo3\Solr\ConnectionManager;
use ApacheSolrForTypo3\Solr\Domain\Site\Site;
use TYPO3\CMS\Backend\Form\Exception as BackendFormException;
use TYPO3\CMS\Backend\Form\FormResultCompiler;
Expand Down Expand Up @@ -118,10 +119,9 @@ public function render(): string
protected function getLanguageUidCoreMap(): array
{
$coreTableMap = [];
$cores = $this->site->getAllSolrConnectionConfigurations();
foreach ($cores as $languageUid => $core) {
$corePath = $core['write']['path'];
$coreTableMap[$languageUid] = $corePath;
$solrServers = GeneralUtility::makeInstance(ConnectionManager::class)->getConnectionsBySite($this->site);
foreach ($solrServers as $languageUid => $solrConnection) {
$coreTableMap[$languageUid] = $solrConnection->getWriteService()->getCorePath();
}
return $coreTableMap;
}
Expand All @@ -137,10 +137,13 @@ protected function buildSelectorItems(array $coresToOptimize): array
{
$selectorItems = [];

foreach ($coresToOptimize as $corePath) {
$icon = 'module-searchbackend_SolrCoreoptimization';
foreach ($coresToOptimize as $systemLanguageId => $corePath) {
$corePath = rtrim($corePath, '/');
$selectorItems[] = [$corePath, $corePath, $icon];
$selectorItems[] = [
'label' => $corePath,
'value' => $corePath,
'icon' => $this->getFlagIdentifierForSystemLanguageId($systemLanguageId),
];
}

return $selectorItems;
Expand All @@ -162,18 +165,31 @@ protected function renderSelectCheckbox(array $items, array $selectedValues): st
/** @var NodeFactory $nodeFactory */
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
$options = [
'type' => 'select',
'renderType' => 'selectCheckBox',
'table' => 'tx_solr_classes_backend_coreselector',
'tableName' => 'tx_solr_classes_backend_coreselector',
'fieldName' => 'additionalFields',
'databaseRow' => [],
'databaseRow' => ['uid' => 0],
'parameterArray' => $parameterArray,
'processedTca' => ['columns' => ['additionalFields' => ['config' => ['type' => 'select']]]],
];

$selectCheckboxResult = $nodeFactory->create($options)->render();
$selectCheckboxResult = $nodeFactory
->create($options)
->render();
$formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
$formResultCompiler->mergeResult($selectCheckboxResult);

$formHtml = $selectCheckboxResult['html'] ?? '';
return $formResultCompiler->addCssFiles() . $formHtml . $formResultCompiler->printNeededJSFunctions();
}

protected function getFlagIdentifierForSystemLanguageId(int|string $systemLanguageId): string
{
$flagIdentifier = $this->site->getTypo3SiteObject()->getLanguageById((int)$systemLanguageId)->getFlagIdentifier();
if (!empty($flagIdentifier)) {
return $flagIdentifier;
}
return 'flags-multiple';
}
}
3 changes: 2 additions & 1 deletion Classes/Backend/IndexingConfigurationSelectorField.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ protected function renderSelectCheckbox(array $items, ?array $selectedValues = [
/** @var NodeFactory $nodeFactory */
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
$options = [
'type' => 'select', 'renderType' => 'selectCheckBox',
'type' => 'select',
'renderType' => 'selectCheckBox',
'table' => 'tx_solr_classes_backend_indexingconfigurationselector',
'tableName' => 'tx_solr_classes_backend_indexingconfigurationselector',
'fieldName' => 'additionalFields',
Expand Down

0 comments on commit c2db99c

Please sign in to comment.