Skip to content

Commit 8a08572

Browse files
committed
[FIX] scheduler task "Optimize index of a site" is not functional
Fixes multiple issues within "Optimize index of a site" component. Relates: #4102 Ports: #4104
1 parent a08b0da commit 8a08572

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

Classes/Backend/CoreSelectorField.php

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
namespace ApacheSolrForTypo3\Solr\Backend;
1717

18+
use ApacheSolrForTypo3\Solr\ConnectionManager;
1819
use ApacheSolrForTypo3\Solr\Domain\Site\Site;
1920
use TYPO3\CMS\Backend\Form\Exception as BackendFormException;
2021
use TYPO3\CMS\Backend\Form\FormResultCompiler;
@@ -130,10 +131,9 @@ public function render(): string
130131
protected function getLanguageUidCoreMap(): array
131132
{
132133
$coreTableMap = [];
133-
$cores = $this->site->getAllSolrConnectionConfigurations();
134-
foreach ($cores as $languageUid => $core) {
135-
$corePath = $core['write']['path'];
136-
$coreTableMap[$languageUid] = $corePath;
134+
$solrServers = GeneralUtility::makeInstance(ConnectionManager::class)->getConnectionsBySite($this->site);
135+
foreach ($solrServers as $languageUid => $solrConnection) {
136+
$coreTableMap[$languageUid] = $solrConnection->getWriteService()->getCorePath();
137137
}
138138
return $coreTableMap;
139139
}
@@ -149,10 +149,13 @@ protected function buildSelectorItems(array $coresToOptimize): array
149149
{
150150
$selectorItems = [];
151151

152-
foreach ($coresToOptimize as $corePath) {
153-
$icon = 'module-searchbackend_SolrCoreoptimization';
152+
foreach ($coresToOptimize as $systemLanguageId => $corePath) {
154153
$corePath = rtrim($corePath, '/');
155-
$selectorItems[] = [$corePath, $corePath, $icon];
154+
$selectorItems[] = [
155+
$corePath,
156+
$corePath,
157+
$this->getFlagIdentifierForSystemLanguageId($systemLanguageId),
158+
];
156159
}
157160

158161
return $selectorItems;
@@ -173,22 +176,36 @@ protected function renderSelectCheckbox(array $items, array $selectedValues): st
173176
'itemFormElValue' => $selectedValues,
174177
'fieldConf' => ['config' => ['items' => $items]],
175178
'fieldTSConfig' => ['noMatchingValue_label' => ''],
179+
'itemFormElID' => '',
176180
];
177181

178182
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
179183
$options = [
184+
'type' => 'select',
180185
'renderType' => 'selectCheckBox',
181-
'table' => 'tx_solr_classes_backend_coreselector',
186+
'tableName' => 'tx_solr_classes_backend_coreselector',
182187
'fieldName' => 'additionalFields',
183-
'databaseRow' => [],
188+
'databaseRow' => ['uid' => 0],
184189
'parameterArray' => $parameterArray,
190+
'processedTca' => ['columns' => ['additionalFields' => ['config' => ['type' => 'select']]]],
185191
];
186192

187-
$selectCheckboxResult = $nodeFactory->create($options)->render();
193+
$selectCheckboxResult = $nodeFactory
194+
->create($options)
195+
->render();
188196
$formResultCompiler = GeneralUtility::makeInstance(FormResultCompiler::class);
189197
$formResultCompiler->mergeResult($selectCheckboxResult);
190198

191199
$formHtml = $selectCheckboxResult['html'] ?? '';
192200
return $formResultCompiler->addCssFiles() . $formHtml . $formResultCompiler->printNeededJSFunctions();
193201
}
202+
203+
protected function getFlagIdentifierForSystemLanguageId($systemLanguageId): string
204+
{
205+
$flagIdentifier = $this->site->getTypo3SiteObject()->getLanguageById((int)$systemLanguageId)->getFlagIdentifier();
206+
if (!empty($flagIdentifier)) {
207+
return $flagIdentifier;
208+
}
209+
return 'flags-multiple';
210+
}
194211
}

Classes/Backend/IndexingConfigurationSelectorField.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@ protected function renderSelectCheckbox(array $items, ?array $selectedValues = [
199199

200200
$nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
201201
$options = [
202-
'type' => 'select', 'renderType' => 'selectCheckBox',
202+
'type' => 'select',
203+
'renderType' => 'selectCheckBox',
203204
'table' => 'tx_solr_classes_backend_indexingconfigurationselector',
204205
'tableName' => 'tx_solr_classes_backend_indexingconfigurationselector',
205206
'fieldName' => 'additionalFields',

0 commit comments

Comments
 (0)