Skip to content

Commit 04c7908

Browse files
author
Markus Günther
committed
[FEATURE] Add flush errors button to backend module
1 parent e6c39e2 commit 04c7908

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

Classes/Backend/SolrModule/IndexQueueModuleController.php

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
use TYPO3\CMS\Core\Messaging\FlashMessage;
2828
use TYPO3\CMS\Core\Utility\GeneralUtility;
29-
29+
use TYPO3\CMS\Core\Database\DatabaseConnection;
3030

3131
/**
3232
* Index Queue Module
@@ -67,7 +67,7 @@ public function indexAction() {
6767
* @return void
6868
*/
6969
public function initializeIndexQueueAction() {
70-
$initializedIndexingConfigurations = array();
70+
$initializedIndexingConfigurations = [];
7171

7272
$itemIndexQueue = GeneralUtility::makeInstance('Tx_Solr_IndexQueue_Queue');
7373
$indexingConfigurationsToInitialize = GeneralUtility::_POST('tx_solr-index-queue-initialization');
@@ -93,7 +93,7 @@ public function initializeIndexQueueAction() {
9393
);
9494
}
9595

96-
$messagesForConfigurations = array();
96+
$messagesForConfigurations = [];
9797
foreach (array_keys($initializedIndexingConfigurations) as $indexingConfigurationName) {
9898
$itemCount = $itemIndexQueue->getItemsCountBySite($this->site, $indexingConfigurationName);
9999
if (!is_int($itemCount)) {
@@ -113,6 +113,32 @@ public function initializeIndexQueueAction() {
113113
$this->forward('index');
114114
}
115115

116+
/**
117+
* Removes all errors in the index queue list. So that the items can be indexed again.
118+
*
119+
* @return void
120+
*/
121+
public function flushLogErrorsAction() {
122+
/** @var DatabaseConnection $database */
123+
$database = $GLOBALS['TYPO3_DB'];
124+
$flushResult = $database->exec_UPDATEquery('tx_solr_indexqueue_item', 'errors NOT LIKE ""', ['errors' => '']);
125+
126+
$message = 'All errors has been flushed';
127+
$severity = FlashMessage::OK;
128+
if (!$flushResult) {
129+
$message = 'An error occured while removing the error log in the index queue.';
130+
$severity = FlashMessage::ERROR;
131+
}
132+
133+
$this->addFlashMessage(
134+
$message,
135+
'Index Queue errors',
136+
$severity
137+
);
138+
139+
$this->forward('index');
140+
}
141+
116142
/**
117143
* Renders a field to select which indexing configurations to initialize.
118144
*
@@ -142,7 +168,7 @@ protected function getIndexQueueStats() {
142168
'pending, erroneous'
143169
);
144170

145-
$stats = array();
171+
$stats = [];
146172
foreach($indexQueueStats as $row) {
147173
if($row['erroneous'] == 1) {
148174
$stats['erroneous'] = $row['count'];

Resources/Private/Templates/IndexQueueModule/Index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ <h2>Indexing Errors</h2>
6565
</tr>
6666
</f:for>
6767
</table>
68+
69+
<f:if condition="{indexqueue_errors}">
70+
<a href="{f:uri.action(controller:'Administration', arguments:{module:'{module.name}', moduleAction:'flushLogErrors'} )}"
71+
class="btn btn-default" >Flush errors</a>
72+
</f:if>
6873
</div>
6974

7075
<div class="span4 well stats_container">

ext_tables.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
ApacheSolrForTypo3\Solr\Backend\SolrModule\AdministrationModuleManager::registerModule(
119119
'ApacheSolrForTypo3.' . $_EXTKEY,
120120
'IndexQueue',
121-
array('index,initializeIndexQueue')
121+
array('index,initializeIndexQueue,flushLogErrors')
122122
);
123123

124124
ApacheSolrForTypo3\Solr\Backend\SolrModule\AdministrationModuleManager::registerModule(

0 commit comments

Comments
 (0)