first commit
This commit is contained in:
@@ -28,12 +28,12 @@ namespace WapplerSystems\Meilisearch\Domain\Index\Queue\GarbageRemover;
|
||||
use WapplerSystems\Meilisearch\ConnectionManager;
|
||||
use WapplerSystems\Meilisearch\GarbageCollectorPostProcessor;
|
||||
use WapplerSystems\Meilisearch\IndexQueue\Queue;
|
||||
use WapplerSystems\Meilisearch\System\Solr\SolrConnection;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\MeilisearchConnection;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
* An implementation ob a garbage remover strategy is responsible to remove all garbage from the index queue and
|
||||
* the solr server for a certain table and uid combination.
|
||||
* the meilisearch server for a certain table and uid combination.
|
||||
*/
|
||||
abstract class AbstractStrategy
|
||||
{
|
||||
@@ -74,7 +74,7 @@ abstract class AbstractStrategy
|
||||
|
||||
/**
|
||||
* A implementation of the GarbageCollection strategy is responsible to remove the garbage from
|
||||
* the indexqueue and from the solr server.
|
||||
* the indexqueue and from the meilisearch server.
|
||||
*
|
||||
* @param string $table
|
||||
* @param int $uid
|
||||
@@ -83,24 +83,24 @@ abstract class AbstractStrategy
|
||||
abstract protected function removeGarbageOfByStrategy($table, $uid);
|
||||
|
||||
/**
|
||||
* Deletes a document from solr and from the index queue.
|
||||
* Deletes a document from meilisearch and from the index queue.
|
||||
*
|
||||
* @param string $table
|
||||
* @param integer $uid
|
||||
*/
|
||||
protected function deleteInSolrAndRemoveFromIndexQueue($table, $uid)
|
||||
protected function deleteInMeilisearchAndRemoveFromIndexQueue($table, $uid)
|
||||
{
|
||||
$this->deleteIndexDocuments($table, $uid);
|
||||
$this->queue->deleteItem($table, $uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a document from solr and updates the item in the index queue (e.g. on page content updates).
|
||||
* Deletes a document from meilisearch and updates the item in the index queue (e.g. on page content updates).
|
||||
*
|
||||
* @param string $table
|
||||
* @param integer $uid
|
||||
*/
|
||||
protected function deleteInSolrAndUpdateIndexQueue($table, $uid)
|
||||
protected function deleteInMeilisearchAndUpdateIndexQueue($table, $uid)
|
||||
{
|
||||
$this->deleteIndexDocuments($table, $uid);
|
||||
$this->queue->updateItem($table, $uid);
|
||||
@@ -118,32 +118,32 @@ abstract class AbstractStrategy
|
||||
$indexQueueItems = $this->queue->getItems($table, $uid);
|
||||
foreach ($indexQueueItems as $indexQueueItem) {
|
||||
$site = $indexQueueItem->getSite();
|
||||
$enableCommitsSetting = $site->getSolrConfiguration()->getEnableCommits();
|
||||
$enableCommitsSetting = $site->getMeilisearchConfiguration()->getEnableCommits();
|
||||
$siteHash = $site->getSiteHash();
|
||||
// a site can have multiple connections (cores / languages)
|
||||
$solrConnections = $this->connectionManager->getConnectionsBySite($site);
|
||||
$meilisearchConnections = $this->connectionManager->getConnectionsBySite($site);
|
||||
if ($language > 0) {
|
||||
$solrConnections = [$language => $solrConnections[$language]];
|
||||
$meilisearchConnections = [$language => $meilisearchConnections[$language]];
|
||||
}
|
||||
$this->deleteRecordInAllSolrConnections($table, $uid, $solrConnections, $siteHash, $enableCommitsSetting);
|
||||
$this->deleteRecordInAllMeilisearchConnections($table, $uid, $meilisearchConnections, $siteHash, $enableCommitsSetting);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the record in all solr connections from that site.
|
||||
* Deletes the record in all meilisearch connections from that site.
|
||||
*
|
||||
* @param string $table
|
||||
* @param int $uid
|
||||
* @param SolrConnection[] $solrConnections
|
||||
* @param MeilisearchConnection[] $meilisearchConnections
|
||||
* @param string $siteHash
|
||||
* @param boolean $enableCommitsSetting
|
||||
*/
|
||||
protected function deleteRecordInAllSolrConnections($table, $uid, $solrConnections, $siteHash, $enableCommitsSetting)
|
||||
protected function deleteRecordInAllMeilisearchConnections($table, $uid, $meilisearchConnections, $siteHash, $enableCommitsSetting)
|
||||
{
|
||||
foreach ($solrConnections as $solr) {
|
||||
$solr->getWriteService()->deleteByQuery('type:' . $table . ' AND uid:' . (int)$uid . ' AND siteHash:' . $siteHash);
|
||||
foreach ($meilisearchConnections as $meilisearch) {
|
||||
$meilisearch->getWriteService()->deleteByQuery('type:' . $table . ' AND uid:' . (int)$uid . ' AND siteHash:' . $siteHash);
|
||||
if ($enableCommitsSetting) {
|
||||
$solr->getWriteService()->commit(false, false);
|
||||
$meilisearch->getWriteService()->commit(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -156,11 +156,11 @@ abstract class AbstractStrategy
|
||||
*/
|
||||
protected function callPostProcessGarbageCollectorHook($table, $uid)
|
||||
{
|
||||
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['postProcessGarbageCollector'])) {
|
||||
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['postProcessGarbageCollector'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['postProcessGarbageCollector'] as $classReference) {
|
||||
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['postProcessGarbageCollector'] as $classReference) {
|
||||
$garbageCollectorPostProcessor = GeneralUtility::makeInstance($classReference);
|
||||
|
||||
if ($garbageCollectorPostProcessor instanceof GarbageCollectorPostProcessor) {
|
||||
|
@@ -52,7 +52,7 @@ class PageStrategy extends AbstractStrategy {
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the relevant page id for an content element update. Deletes the page from solr and requeues the
|
||||
* Determines the relevant page id for an content element update. Deletes the page from meilisearch and requeues the
|
||||
* page for a reindex.
|
||||
*
|
||||
* @param int $ttContentUid
|
||||
@@ -60,7 +60,7 @@ class PageStrategy extends AbstractStrategy {
|
||||
protected function collectPageGarbageByContentChange($ttContentUid)
|
||||
{
|
||||
$contentElement = BackendUtility::getRecord('tt_content', $ttContentUid, 'uid, pid', '', false);
|
||||
$this->deleteInSolrAndUpdateIndexQueue('pages', $contentElement['pid']);
|
||||
$this->deleteInMeilisearchAndUpdateIndexQueue('pages', $contentElement['pid']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ class PageStrategy extends AbstractStrategy {
|
||||
if (!empty($pageOverlay['l10n_parent']) && intval($pageOverlay['l10n_parent']) !== 0) {
|
||||
$this->deleteIndexDocuments('pages', (int)$pageOverlay['l10n_parent'], (int)$pageOverlay['sys_language_uid']);
|
||||
} else {
|
||||
$this->deleteInSolrAndRemoveFromIndexQueue('pages', $uid);
|
||||
$this->deleteInMeilisearchAndRemoveFromIndexQueue('pages', $uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -38,6 +38,6 @@ class RecordStrategy extends AbstractStrategy {
|
||||
*/
|
||||
protected function removeGarbageOfByStrategy($table, $uid)
|
||||
{
|
||||
$this->deleteInSolrAndRemoveFromIndexQueue($table, $uid);
|
||||
$this->deleteInMeilisearchAndRemoveFromIndexQueue($table, $uid);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user