Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX:11.5] scheduler task "Optimize index of a site" is not functional #4105

Merged
Merged
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
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
Loading