Skip to content

Commit

Permalink
[TASK] Show error r
Browse files Browse the repository at this point in the history
Show the error regarding the disabled MySQL
indexes only if the indexer is not running.
When the indexer is still running it's
normal behavior that the MySQL indexes are
disabled so there should not be an error shown.
Additionally, show an information if
the index is empty.
  • Loading branch information
christianbltr committed Jun 21, 2024
1 parent 57b638e commit 6bade6a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
30 changes: 20 additions & 10 deletions Classes/Controller/BackendModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,12 @@ public function startIndexingAction(ServerRequestInterface $request, ModuleTempl
$indexer = GeneralUtility::makeInstance(IndexerRunner::class);
$indexerConfigurations = $indexer->getConfigurations();
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$mySqlIndexEnabled = SanityCheckUtility::IsIndexTableIndexesEnabled();

if ($mySqlIndexEnabled) {
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 12) {
$this->pageRenderer->addJsFile('EXT:ke_search/Resources/Public/JavaScript/v11/getIndexerStatusRequest.js');
} else {
// @phpstan-ignore-next-line
$this->pageRenderer->loadJavaScriptModule('@tpwd/ke-search/getIndexerStatusRequest.js');
}
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() < 12) {
$this->pageRenderer->addJsFile('EXT:ke_search/Resources/Public/JavaScript/v11/getIndexerStatusRequest.js');
} else {
// @phpstan-ignore-next-line
$this->pageRenderer->loadJavaScriptModule('@tpwd/ke-search/getIndexerStatusRequest.js');
}

$indexingMode = (int)($request->getQueryParams()['indexingMode'] ?? IndexerBase::INDEXING_MODE_FULL);
Expand Down Expand Up @@ -274,12 +271,14 @@ public function startIndexingAction(ServerRequestInterface $request, ModuleTempl
$moduleTemplate->getView()->setLayoutRootPaths(['EXT:ke_search/Resources/Private/Layouts/']);
$moduleTemplate->getView()->setTemplatePathAndFilename('EXT:ke_search/Resources/Private/Templates/BackendModule/StartIndexing.html');
$moduleTemplate->getView()->assign('content', $content);
$moduleTemplate->getView()->assign('mySqlIndexEnabled', $mySqlIndexEnabled);
$moduleTemplate->getView()->assign('mySqlIndexEnabled', SanityCheckUtility::IsIndexTableIndexesEnabled());
$moduleTemplate->getView()->assign('indexerIsRunning', $this->indexerStatusService->isRunning());
// @extensionScannerIgnoreLine
return new HtmlResponse($moduleTemplate->renderContent());
}
$moduleTemplate->assign('content', $content);
$moduleTemplate->assign('mySqlIndexEnabled', $mySqlIndexEnabled);
$moduleTemplate->assign('mySqlIndexEnabled', SanityCheckUtility::IsIndexTableIndexesEnabled());
$moduleTemplate->assign('indexerIsRunning', $this->indexerStatusService->isRunning());
return $moduleTemplate->renderResponse('BackendModule/StartIndexing');
}

Expand Down Expand Up @@ -559,6 +558,17 @@ public function printNumberOfRecords()

$content .= '</table></div>';
$content .= '</div></div></div>';
} else {
$content .= '<div class="row"><div class="col-md-8">';
$content .= '<div class="alert alert-info">';
$content .=
LocalizationUtility::translate(
'LLL:EXT:ke_search/Resources/Private/Language/locallang_mod.xlf:index_is_empty',
'KeSearch'
);
$content .= '</div>';
$content .= '</div></div>';

}

return $content;
Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Language/locallang_mod.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<trans-unit id="index_contains" resname="index_contains" >
<source>The index currently contains</source>
</trans-unit>
<trans-unit id="index_is_empty" resname="index_is_empty" >
<source>The index is empty.</source>
</trans-unit>
<trans-unit id="last_indexing" resname="last_indexing" >
<source>Last indexing was done on</source>
</trans-unit>
Expand Down
4 changes: 2 additions & 2 deletions Resources/Private/Templates/BackendModule/StartIndexing.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<div class="alert alert-notice">Waiting for indexer status.</div>
</div>
</div>
<f:if condition="!{mySqlIndexEnabled}">
<div class="row">
<f:if condition="!{mySqlIndexEnabled} && !{indexerIsRunning}">
<div class="row" id="kesearch-indexes-disabled-warning">
<div class="col-md-8">
<div class="alert alert-danger">The MySQL indexes in the table 'tx_kesearch_index' are disabled.
Searching in the frontend will not work.
Expand Down
2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/getIndexerStatusRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ setInterval(function () {
const indexerStatus = await response.resolve();
document.getElementById("kesearch-indexer-status").innerHTML = indexerStatus.html;
if (indexerStatus.running === true) {
let hideElements= ["kesearch-indexer-overview", "kesearch-button-start-full", "kesearch-indexer-report", "kesearch-button-start-incremental", "kesearch-button-reload"];
let hideElements= ["kesearch-indexer-overview", "kesearch-button-start-full", "kesearch-indexer-report", "kesearch-button-start-incremental", "kesearch-button-reload", "kesearch-indexes-disabled-warning"];
hideElements.forEach((element) => {
if (document.getElementById(element)) {
document.getElementById(element).style.display = 'none';
Expand Down

0 comments on commit 6bade6a

Please sign in to comment.