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
Ports: #4104
  • Loading branch information
dkd-kaehm committed Jul 11, 2024
1 parent a08b0da commit 8a08572
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
37 changes: 27 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 @@ -130,10 +131,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 @@ -149,10 +149,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[] = [
$corePath,
$corePath,
$this->getFlagIdentifierForSystemLanguageId($systemLanguageId),
];
}

return $selectorItems;
Expand All @@ -173,22 +176,36 @@ protected function renderSelectCheckbox(array $items, array $selectedValues): st
'itemFormElValue' => $selectedValues,
'fieldConf' => ['config' => ['items' => $items]],
'fieldTSConfig' => ['noMatchingValue_label' => ''],
'itemFormElID' => '',
];

$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($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 @@ -199,7 +199,8 @@ protected function renderSelectCheckbox(array $items, ?array $selectedValues = [

$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 8a08572

Please sign in to comment.