first commit
This commit is contained in:
@@ -27,7 +27,7 @@ namespace WapplerSystems\Meilisearch\IndexQueue;
|
||||
use WapplerSystems\Meilisearch\ContentObject\Classification;
|
||||
use WapplerSystems\Meilisearch\ContentObject\Multivalue;
|
||||
use WapplerSystems\Meilisearch\ContentObject\Relation;
|
||||
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
|
||||
use TYPO3\CMS\Core\Core\Environment;
|
||||
use TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
@@ -57,12 +57,12 @@ abstract class AbstractIndexer
|
||||
protected static $unAllowedOverrideFields = ['type'];
|
||||
|
||||
/**
|
||||
* @param string $solrFieldName
|
||||
* @param string $meilisearchFieldName
|
||||
* @return bool
|
||||
*/
|
||||
public static function isAllowedToOverrideField($solrFieldName)
|
||||
public static function isAllowedToOverrideField($meilisearchFieldName)
|
||||
{
|
||||
return !in_array($solrFieldName, static::$unAllowedOverrideFields);
|
||||
return !in_array($meilisearchFieldName, static::$unAllowedOverrideFields);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,28 +76,28 @@ abstract class AbstractIndexer
|
||||
protected function addDocumentFieldsFromTyposcript(Document $document, array $indexingConfiguration, array $data) {
|
||||
$data = static::addVirtualContentFieldToRecord($document, $data);
|
||||
|
||||
// mapping of record fields => solr document fields, resolving cObj
|
||||
foreach ($indexingConfiguration as $solrFieldName => $recordFieldName) {
|
||||
// mapping of record fields => meilisearch document fields, resolving cObj
|
||||
foreach ($indexingConfiguration as $meilisearchFieldName => $recordFieldName) {
|
||||
if (is_array($recordFieldName)) {
|
||||
// configuration for a content object, skipping
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!static::isAllowedToOverrideField($solrFieldName)) {
|
||||
if (!static::isAllowedToOverrideField($meilisearchFieldName)) {
|
||||
throw new InvalidFieldNameException(
|
||||
'Must not overwrite field .' . $solrFieldName,
|
||||
'Must not overwrite field .' . $meilisearchFieldName,
|
||||
1435441863
|
||||
);
|
||||
}
|
||||
|
||||
$fieldValue = $this->resolveFieldValue($indexingConfiguration, $solrFieldName, $data);
|
||||
$fieldValue = $this->resolveFieldValue($indexingConfiguration, $meilisearchFieldName, $data);
|
||||
|
||||
if (is_array($fieldValue)) {
|
||||
// multi value
|
||||
$document->setField($solrFieldName, $fieldValue);
|
||||
$document->setField($meilisearchFieldName, $fieldValue);
|
||||
} else {
|
||||
if ($fieldValue !== '' && $fieldValue !== null) {
|
||||
$document->setField($solrFieldName, $fieldValue);
|
||||
$document->setField($meilisearchFieldName, $fieldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ abstract class AbstractIndexer
|
||||
|
||||
|
||||
/**
|
||||
* Add's the content of the field 'content' from the solr document as virtual field __solr_content in the record,
|
||||
* Add's the content of the field 'content' from the meilisearch document as virtual field __meilisearch_content in the record,
|
||||
* to have it available in typoscript.
|
||||
*
|
||||
* @param Document $document
|
||||
@@ -117,7 +117,7 @@ abstract class AbstractIndexer
|
||||
public static function addVirtualContentFieldToRecord(Document $document, array $data): array
|
||||
{
|
||||
if (isset($document['content'])) {
|
||||
$data['__solr_content'] = $document['content'];
|
||||
$data['__meilisearch_content'] = $document['content'];
|
||||
return $data;
|
||||
}
|
||||
return $data;
|
||||
@@ -131,18 +131,18 @@ abstract class AbstractIndexer
|
||||
* is taken.
|
||||
*
|
||||
* @param array $indexingConfiguration Indexing configuration as defined in plugin.tx_meilisearch_index.queue.[indexingConfigurationName].fields
|
||||
* @param string $solrFieldName A Solr field name that is configured in the indexing configuration
|
||||
* @param string $meilisearchFieldName A Meilisearch field name that is configured in the indexing configuration
|
||||
* @param array $data A record or item's data
|
||||
* @return string The resolved string value to be indexed
|
||||
*/
|
||||
protected function resolveFieldValue(
|
||||
array $indexingConfiguration,
|
||||
$solrFieldName,
|
||||
$meilisearchFieldName,
|
||||
array $data
|
||||
) {
|
||||
$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
|
||||
|
||||
if (isset($indexingConfiguration[$solrFieldName . '.'])) {
|
||||
if (isset($indexingConfiguration[$meilisearchFieldName . '.'])) {
|
||||
// configuration found => need to resolve a cObj
|
||||
|
||||
// need to change directory to make IMAGE content objects work in BE context
|
||||
@@ -152,21 +152,21 @@ abstract class AbstractIndexer
|
||||
|
||||
$contentObject->start($data, $this->type);
|
||||
$fieldValue = $contentObject->cObjGetSingle(
|
||||
$indexingConfiguration[$solrFieldName],
|
||||
$indexingConfiguration[$solrFieldName . '.']
|
||||
$indexingConfiguration[$meilisearchFieldName],
|
||||
$indexingConfiguration[$meilisearchFieldName . '.']
|
||||
);
|
||||
|
||||
chdir($backupWorkingDirectory);
|
||||
|
||||
if ($this->isSerializedValue($indexingConfiguration,
|
||||
$solrFieldName)
|
||||
$meilisearchFieldName)
|
||||
) {
|
||||
$fieldValue = unserialize($fieldValue);
|
||||
}
|
||||
} elseif (substr($indexingConfiguration[$solrFieldName], 0,
|
||||
} elseif (substr($indexingConfiguration[$meilisearchFieldName], 0,
|
||||
1) === '<'
|
||||
) {
|
||||
$referencedTsPath = trim(substr($indexingConfiguration[$solrFieldName],
|
||||
$referencedTsPath = trim(substr($indexingConfiguration[$meilisearchFieldName],
|
||||
1));
|
||||
$typoScriptParser = GeneralUtility::makeInstance(TypoScriptParser::class);
|
||||
// $name and $conf is loaded with the referenced values.
|
||||
@@ -184,18 +184,18 @@ abstract class AbstractIndexer
|
||||
chdir($backupWorkingDirectory);
|
||||
|
||||
if ($this->isSerializedValue($indexingConfiguration,
|
||||
$solrFieldName)
|
||||
$meilisearchFieldName)
|
||||
) {
|
||||
$fieldValue = unserialize($fieldValue);
|
||||
}
|
||||
} else {
|
||||
$fieldValue = $data[$indexingConfiguration[$solrFieldName]];
|
||||
$fieldValue = $data[$indexingConfiguration[$meilisearchFieldName]];
|
||||
}
|
||||
|
||||
// detect and correct type for dynamic fields
|
||||
|
||||
// find last underscore, substr from there, cut off last character (S/M)
|
||||
$fieldType = substr($solrFieldName, strrpos($solrFieldName, '_') + 1,
|
||||
$fieldType = substr($meilisearchFieldName, strrpos($meilisearchFieldName, '_') + 1,
|
||||
-1);
|
||||
if (is_array($fieldValue)) {
|
||||
foreach ($fieldValue as $key => $value) {
|
||||
@@ -217,17 +217,17 @@ abstract class AbstractIndexer
|
||||
* unserialized.
|
||||
*
|
||||
* @param array $indexingConfiguration Current item's indexing configuration
|
||||
* @param string $solrFieldName Current field being indexed
|
||||
* @param string $meilisearchFieldName Current field being indexed
|
||||
* @return bool TRUE if the value is expected to be serialized, FALSE otherwise
|
||||
*/
|
||||
public static function isSerializedValue(array $indexingConfiguration, $solrFieldName)
|
||||
public static function isSerializedValue(array $indexingConfiguration, $meilisearchFieldName)
|
||||
{
|
||||
$isSerialized = static::isSerializedResultFromRegisteredHook($indexingConfiguration, $solrFieldName);
|
||||
$isSerialized = static::isSerializedResultFromRegisteredHook($indexingConfiguration, $meilisearchFieldName);
|
||||
if ($isSerialized === true) {
|
||||
return $isSerialized;
|
||||
}
|
||||
|
||||
$isSerialized = static::isSerializedResultFromCustomContentElement($indexingConfiguration, $solrFieldName);
|
||||
$isSerialized = static::isSerializedResultFromCustomContentElement($indexingConfiguration, $meilisearchFieldName);
|
||||
return $isSerialized;
|
||||
}
|
||||
|
||||
@@ -235,25 +235,25 @@ abstract class AbstractIndexer
|
||||
* Checks if the response comes from a custom content element that returns a serialized value.
|
||||
*
|
||||
* @param array $indexingConfiguration
|
||||
* @param string $solrFieldName
|
||||
* @param string $meilisearchFieldName
|
||||
* @return bool
|
||||
*/
|
||||
protected static function isSerializedResultFromCustomContentElement(array $indexingConfiguration, $solrFieldName): bool
|
||||
protected static function isSerializedResultFromCustomContentElement(array $indexingConfiguration, $meilisearchFieldName): bool
|
||||
{
|
||||
$isSerialized = false;
|
||||
|
||||
// SOLR_CLASSIFICATION - always returns serialized array
|
||||
if ($indexingConfiguration[$solrFieldName] == Classification::CONTENT_OBJECT_NAME) {
|
||||
if ($indexingConfiguration[$meilisearchFieldName] == Classification::CONTENT_OBJECT_NAME) {
|
||||
$isSerialized = true;
|
||||
}
|
||||
|
||||
// SOLR_MULTIVALUE - always returns serialized array
|
||||
if ($indexingConfiguration[$solrFieldName] == Multivalue::CONTENT_OBJECT_NAME) {
|
||||
if ($indexingConfiguration[$meilisearchFieldName] == Multivalue::CONTENT_OBJECT_NAME) {
|
||||
$isSerialized = true;
|
||||
}
|
||||
|
||||
// SOLR_RELATION - returns serialized array if multiValue option is set
|
||||
if ($indexingConfiguration[$solrFieldName] == Relation::CONTENT_OBJECT_NAME && !empty($indexingConfiguration[$solrFieldName . '.']['multiValue'])) {
|
||||
if ($indexingConfiguration[$meilisearchFieldName] == Relation::CONTENT_OBJECT_NAME && !empty($indexingConfiguration[$meilisearchFieldName . '.']['multiValue'])) {
|
||||
$isSerialized = true;
|
||||
}
|
||||
|
||||
@@ -264,23 +264,23 @@ abstract class AbstractIndexer
|
||||
* Checks registered hooks if a SerializedValueDetector detects a serialized response.
|
||||
*
|
||||
* @param array $indexingConfiguration
|
||||
* @param string $solrFieldName
|
||||
* @param string $meilisearchFieldName
|
||||
* @return bool
|
||||
*/
|
||||
protected static function isSerializedResultFromRegisteredHook(array $indexingConfiguration, $solrFieldName)
|
||||
protected static function isSerializedResultFromRegisteredHook(array $indexingConfiguration, $meilisearchFieldName)
|
||||
{
|
||||
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['detectSerializedValue'])) {
|
||||
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['detectSerializedValue'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['detectSerializedValue'] as $classReference) {
|
||||
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['detectSerializedValue'] as $classReference) {
|
||||
$serializedValueDetector = GeneralUtility::makeInstance($classReference);
|
||||
if (!$serializedValueDetector instanceof SerializedValueDetector) {
|
||||
$message = get_class($serializedValueDetector) . ' must implement interface ' . SerializedValueDetector::class;
|
||||
throw new \UnexpectedValueException($message, 1404471741);
|
||||
}
|
||||
|
||||
$isSerialized = (boolean)$serializedValueDetector->isSerializedValue($indexingConfiguration, $solrFieldName);
|
||||
$isSerialized = (boolean)$serializedValueDetector->isSerializedValue($indexingConfiguration, $meilisearchFieldName);
|
||||
if ($isSerialized) {
|
||||
return true;
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ namespace WapplerSystems\Meilisearch\IndexQueue;
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
|
||||
|
||||
/**
|
||||
* Interface that defines the method an indexer must implement to provide
|
||||
|
@@ -4,7 +4,7 @@ namespace WapplerSystems\Meilisearch\IndexQueue\Exception;
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2010-2017 dkd Internet Service GmbH <solr-eb-support@dkd.de>
|
||||
* (c) 2010-2017 dkd Internet Service GmbH <meilisearch-eb-support@dkd.de>
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
|
@@ -4,7 +4,7 @@ namespace WapplerSystems\Meilisearch\IndexQueue\Exception;
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2010-2017 dkd Internet Service GmbH <solr-eb-support@dkd.de>
|
||||
* (c) 2010-2017 dkd Internet Service GmbH <meilisearch-eb-support@dkd.de>
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
|
@@ -26,7 +26,7 @@ namespace WapplerSystems\Meilisearch\IndexQueue\FrontendHelper;
|
||||
|
||||
use WapplerSystems\Meilisearch\IndexQueue\PageIndexerRequest;
|
||||
use WapplerSystems\Meilisearch\IndexQueue\PageIndexerResponse;
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
|
||||
|
||||
@@ -59,7 +59,7 @@ abstract class AbstractFrontendHelper implements FrontendHelper
|
||||
protected $action = null;
|
||||
|
||||
/**
|
||||
* @var SolrLogManager
|
||||
* @var MeilisearchLogManager
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
@@ -99,11 +99,11 @@ abstract class AbstractFrontendHelper implements FrontendHelper
|
||||
) {
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
$this->logger = GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->logger = GeneralUtility::makeInstance(MeilisearchLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
|
||||
if ($request->getParameter('loggingEnabled')) {
|
||||
$this->logger->log(
|
||||
SolrLogManager::INFO,
|
||||
MeilisearchLogManager::INFO,
|
||||
'Page indexer request received',
|
||||
[
|
||||
'request' => (array)$request,
|
||||
|
@@ -45,7 +45,7 @@ class AuthorizationService extends AbstractAuthenticationService
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const SOLR_INDEXER_USERNAME = '__SolrIndexerUser__';
|
||||
const SOLR_INDEXER_USERNAME = '__MeilisearchIndexerUser__';
|
||||
|
||||
/**
|
||||
* Gets a fake frontend user record to allow access to protected pages.
|
||||
@@ -115,7 +115,7 @@ class AuthorizationService extends AbstractAuthenticationService
|
||||
$groupData[] = [
|
||||
'uid' => $groupId,
|
||||
'pid' => 0,
|
||||
'title' => '__SolrIndexerGroup__',
|
||||
'title' => '__MeilisearchIndexerGroup__',
|
||||
'TSconfig' => ''
|
||||
];
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ use WapplerSystems\Meilisearch\IndexQueue\AbstractIndexer;
|
||||
use WapplerSystems\Meilisearch\IndexQueue\InvalidFieldNameException;
|
||||
use WapplerSystems\Meilisearch\SubstitutePageIndexer;
|
||||
use WapplerSystems\Meilisearch\System\Configuration\TypoScriptConfiguration;
|
||||
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
|
||||
use WapplerSystems\Meilisearch\Util;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
||||
@@ -57,7 +57,7 @@ class PageFieldMappingIndexer implements SubstitutePageIndexer
|
||||
*/
|
||||
public function __construct(TypoScriptConfiguration $configuration = null)
|
||||
{
|
||||
$this->configuration = $configuration == null ? Util::getSolrConfiguration() : $configuration;
|
||||
$this->configuration = $configuration == null ? Util::getMeilisearchConfiguration() : $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ class PageFieldMappingIndexer implements SubstitutePageIndexer
|
||||
* plugin.tx_meilisearch.index.queue.pages.fields.
|
||||
*
|
||||
* @param Document $pageDocument The original page document.
|
||||
* @return Document A Apache Solr Document object that replace the default page document
|
||||
* @return Document A Meilisearch Document object that replace the default page document
|
||||
*/
|
||||
public function getPageDocument(Document $pageDocument)
|
||||
{
|
||||
@@ -131,16 +131,16 @@ class PageFieldMappingIndexer implements SubstitutePageIndexer
|
||||
* Allows to put the page record through cObj processing if wanted / needed.
|
||||
* Otherwise the plain page record field value is used.
|
||||
*
|
||||
* @param string $solrFieldName The Solr field name to resolve the value from the item's record
|
||||
* @param string $meilisearchFieldName The Meilisearch field name to resolve the value from the item's record
|
||||
* @return string The resolved string value to be indexed
|
||||
*/
|
||||
protected function resolveFieldValue($solrFieldName, Document $pageDocument)
|
||||
protected function resolveFieldValue($meilisearchFieldName, Document $pageDocument)
|
||||
{
|
||||
$pageRecord = $GLOBALS['TSFE']->page;
|
||||
|
||||
$pageIndexingConfiguration = $this->configuration->getIndexQueueFieldsConfigurationByConfigurationName($this->pageIndexingConfigurationName);
|
||||
|
||||
if (isset($pageIndexingConfiguration[$solrFieldName . '.'])) {
|
||||
if (isset($pageIndexingConfiguration[$meilisearchFieldName . '.'])) {
|
||||
$pageRecord = AbstractIndexer::addVirtualContentFieldToRecord($pageDocument, $pageRecord);
|
||||
|
||||
// configuration found => need to resolve a cObj
|
||||
@@ -148,15 +148,15 @@ class PageFieldMappingIndexer implements SubstitutePageIndexer
|
||||
$contentObject->start($pageRecord, 'pages');
|
||||
|
||||
$fieldValue = $contentObject->cObjGetSingle(
|
||||
$pageIndexingConfiguration[$solrFieldName],
|
||||
$pageIndexingConfiguration[$solrFieldName . '.']
|
||||
$pageIndexingConfiguration[$meilisearchFieldName],
|
||||
$pageIndexingConfiguration[$meilisearchFieldName . '.']
|
||||
);
|
||||
|
||||
if (AbstractIndexer::isSerializedValue($pageIndexingConfiguration, $solrFieldName)) {
|
||||
if (AbstractIndexer::isSerializedValue($pageIndexingConfiguration, $meilisearchFieldName)) {
|
||||
$fieldValue = unserialize($fieldValue);
|
||||
}
|
||||
} else {
|
||||
$fieldValue = $pageRecord[$pageIndexingConfiguration[$solrFieldName]];
|
||||
$fieldValue = $pageRecord[$pageIndexingConfiguration[$meilisearchFieldName]];
|
||||
}
|
||||
|
||||
return $fieldValue;
|
||||
|
@@ -29,9 +29,9 @@ use WapplerSystems\Meilisearch\Access\Rootline;
|
||||
use WapplerSystems\Meilisearch\ConnectionManager;
|
||||
use WapplerSystems\Meilisearch\IndexQueue\Item;
|
||||
use WapplerSystems\Meilisearch\IndexQueue\Queue;
|
||||
use WapplerSystems\Meilisearch\NoSolrConnectionFoundException;
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Solr\SolrConnection;
|
||||
use WapplerSystems\Meilisearch\NoMeilisearchConnectionFoundException;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\MeilisearchConnection;
|
||||
use WapplerSystems\Meilisearch\Typo3PageIndexer;
|
||||
use WapplerSystems\Meilisearch\Util;
|
||||
use Exception;
|
||||
@@ -91,7 +91,7 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
|
||||
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageIndexing'][__CLASS__] = $pageIndexingHookRegistration;
|
||||
|
||||
// indexes fields defined in plugin.tx_meilisearch.index.queue.pages.fields
|
||||
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['Indexer']['indexPageSubstitutePageDocument'][PageFieldMappingIndexer::class] = PageFieldMappingIndexer::class;
|
||||
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['Indexer']['indexPageSubstitutePageDocument'][PageFieldMappingIndexer::class] = PageFieldMappingIndexer::class;
|
||||
|
||||
$this->registerAuthorizationService();
|
||||
}
|
||||
@@ -170,13 +170,13 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
|
||||
$overrulingPriority = $this->getHighestAuthenticationServicePriority() + 1;
|
||||
|
||||
ExtensionManagementUtility::addService(
|
||||
'solr', // extension key
|
||||
'meilisearch', // extension key
|
||||
'auth', // service type
|
||||
AuthorizationService::class,
|
||||
// service key
|
||||
[// service meta data
|
||||
'title' => 'Solr Indexer Authorization',
|
||||
'description' => 'Authorizes the Solr Index Queue indexer to access protected pages.',
|
||||
'title' => 'Meilisearch Indexer Authorization',
|
||||
'description' => 'Authorizes the Meilisearch Index Queue indexer to access protected pages.',
|
||||
|
||||
'subtype' => 'getUserFE,authUserFE,getGroupsFE',
|
||||
|
||||
@@ -187,7 +187,7 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
|
||||
'os' => '',
|
||||
'exec' => '',
|
||||
|
||||
'classFile' => ExtensionManagementUtility::extPath('solr') . 'Classes/IndexQueue/FrontendHelper/AuthorizationService.php',
|
||||
'classFile' => ExtensionManagementUtility::extPath('meilisearch') . 'Classes/IndexQueue/FrontendHelper/AuthorizationService.php',
|
||||
'className' => AuthorizationService::class,
|
||||
]
|
||||
);
|
||||
@@ -263,16 +263,16 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
|
||||
*/
|
||||
public function hook_indexContent(TypoScriptFrontendController $page)
|
||||
{
|
||||
$this->logger = GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->logger = GeneralUtility::makeInstance(MeilisearchLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
|
||||
$this->page = $page;
|
||||
$configuration = Util::getSolrConfiguration();
|
||||
$configuration = Util::getMeilisearchConfiguration();
|
||||
|
||||
$logPageIndexed = $configuration->getLoggingIndexingPageIndexed();
|
||||
if (!$this->page->config['config']['index_enable']) {
|
||||
if ($logPageIndexed) {
|
||||
$this->logger->log(
|
||||
SolrLogManager::ERROR,
|
||||
MeilisearchLogManager::ERROR,
|
||||
'Indexing is disabled. Set config.index_enable = 1 .'
|
||||
);
|
||||
}
|
||||
@@ -285,32 +285,32 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
|
||||
throw new UnexpectedValueException('Can not get index queue item', 1482162337);
|
||||
}
|
||||
|
||||
$solrConnection = $this->getSolrConnection($indexQueueItem);
|
||||
$meilisearchConnection = $this->getMeilisearchConnection($indexQueueItem);
|
||||
|
||||
/** @var $indexer Typo3PageIndexer */
|
||||
$indexer = GeneralUtility::makeInstance(Typo3PageIndexer::class, /** @scrutinizer ignore-type */ $page);
|
||||
$indexer->setSolrConnection($solrConnection);
|
||||
$indexer->setMeilisearchConnection($meilisearchConnection);
|
||||
$indexer->setPageAccessRootline($this->getAccessRootline());
|
||||
$indexer->setPageUrl($this->generatePageUrl());
|
||||
$indexer->setMountPointParameter($GLOBALS['TSFE']->MP);
|
||||
$indexer->setIndexQueueItem($indexQueueItem);
|
||||
|
||||
$this->responseData['pageIndexed'] = (int)$indexer->indexPage();
|
||||
$this->responseData['originalPageDocument'] = (array)$indexer->getPageSolrDocument();
|
||||
$this->responseData['solrConnection'] = [
|
||||
$this->responseData['originalPageDocument'] = (array)$indexer->getPageMeilisearchDocument();
|
||||
$this->responseData['meilisearchConnection'] = [
|
||||
'rootPage' => $indexQueueItem->getRootPageUid(),
|
||||
'sys_language_uid' => Util::getLanguageUid(),
|
||||
'solr' => (string)$solrConnection->getNode('write')
|
||||
'meilisearch' => (string)$meilisearchConnection->getNode('write')
|
||||
];
|
||||
|
||||
$documentsSentToSolr = $indexer->getDocumentsSentToSolr();
|
||||
foreach ($documentsSentToSolr as $document) {
|
||||
$this->responseData['documentsSentToSolr'][] = (array)$document;
|
||||
$documentsSentToMeilisearch = $indexer->getDocumentsSentToMeilisearch();
|
||||
foreach ($documentsSentToMeilisearch as $document) {
|
||||
$this->responseData['documentsSentToMeilisearch'][] = (array)$document;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
if ($configuration->getLoggingExceptions()) {
|
||||
$this->logger->log(
|
||||
SolrLogManager::ERROR,
|
||||
MeilisearchLogManager::ERROR,
|
||||
'Exception while trying to index page ' . $page->id,
|
||||
[
|
||||
$e->__toString()
|
||||
@@ -321,7 +321,7 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
|
||||
|
||||
if ($logPageIndexed) {
|
||||
$success = $this->responseData['pageIndexed'] ? 'Success' : 'Failed';
|
||||
$severity = $this->responseData['pageIndexed'] ? SolrLogManager::NOTICE : SolrLogManager::ERROR;
|
||||
$severity = $this->responseData['pageIndexed'] ? MeilisearchLogManager::NOTICE : MeilisearchLogManager::ERROR;
|
||||
|
||||
$this->logger->log(
|
||||
$severity,
|
||||
@@ -332,14 +332,14 @@ class PageIndexer extends AbstractFrontendHelper implements SingletonInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the solr connection to use for indexing the page based on the
|
||||
* Gets the meilisearch connection to use for indexing the page based on the
|
||||
* Index Queue item's properties.
|
||||
*
|
||||
* @param Item $indexQueueItem
|
||||
* @return SolrConnection Solr server connection
|
||||
* @throws NoSolrConnectionFoundException
|
||||
* @return MeilisearchConnection Meilisearch server connection
|
||||
* @throws NoMeilisearchConnectionFoundException
|
||||
*/
|
||||
protected function getSolrConnection(Item $indexQueueItem)
|
||||
protected function getMeilisearchConnection(Item $indexQueueItem)
|
||||
{
|
||||
/** @var $connectionManager ConnectionManager */
|
||||
$connectionManager = GeneralUtility::makeInstance(ConnectionManager::class);
|
||||
|
@@ -24,7 +24,7 @@ namespace WapplerSystems\Meilisearch\IndexQueue\FrontendHelper;
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use TYPO3\CMS\Core\SingletonInterface;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Frontend\ContentObject\ContentObjectPostInitHookInterface;
|
||||
@@ -66,7 +66,7 @@ class UserGroupDetector extends AbstractFrontendHelper implements
|
||||
protected $frontendGroups = [];
|
||||
|
||||
/**
|
||||
* @var \WapplerSystems\Meilisearch\System\Logging\SolrLogManager
|
||||
* @var \WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
@@ -202,7 +202,7 @@ class UserGroupDetector extends AbstractFrontendHelper implements
|
||||
} else {
|
||||
if ($this->request->getParameter('loggingEnabled')) {
|
||||
$this->logger->log(
|
||||
SolrLogManager::INFO,
|
||||
MeilisearchLogManager::INFO,
|
||||
'Access restriction found',
|
||||
[
|
||||
'groups' => $frontendGroups,
|
||||
|
@@ -25,16 +25,16 @@ namespace WapplerSystems\Meilisearch\IndexQueue;
|
||||
***************************************************************/
|
||||
|
||||
use WapplerSystems\Meilisearch\ConnectionManager;
|
||||
use WapplerSystems\Meilisearch\Domain\Search\ApacheSolrDocument\Builder;
|
||||
use WapplerSystems\Meilisearch\Domain\Search\ApacheMeilisearchDocument\Builder;
|
||||
use WapplerSystems\Meilisearch\FieldProcessor\Service;
|
||||
use WapplerSystems\Meilisearch\FrontendEnvironment;
|
||||
use WapplerSystems\Meilisearch\NoSolrConnectionFoundException;
|
||||
use WapplerSystems\Meilisearch\NoMeilisearchConnectionFoundException;
|
||||
use WapplerSystems\Meilisearch\Domain\Site\Site;
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Records\Pages\PagesRepository;
|
||||
use WapplerSystems\Meilisearch\System\Solr\Document\Document;
|
||||
use WapplerSystems\Meilisearch\System\Solr\ResponseAdapter;
|
||||
use WapplerSystems\Meilisearch\System\Solr\SolrConnection;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\Document\Document;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\ResponseAdapter;
|
||||
use WapplerSystems\Meilisearch\System\Meilisearch\MeilisearchConnection;
|
||||
use Exception;
|
||||
use RuntimeException;
|
||||
use Solarium\Exception\HttpException;
|
||||
@@ -61,11 +61,11 @@ class Indexer extends AbstractIndexer
|
||||
# TODO change to singular $document instead of plural $documents
|
||||
|
||||
/**
|
||||
* A Solr service instance to interact with the Solr server
|
||||
* A Meilisearch service instance to interact with the Meilisearch server
|
||||
*
|
||||
* @var SolrConnection
|
||||
* @var MeilisearchConnection
|
||||
*/
|
||||
protected $solr;
|
||||
protected $meilisearch;
|
||||
|
||||
/**
|
||||
* @var ConnectionManager
|
||||
@@ -87,7 +87,7 @@ class Indexer extends AbstractIndexer
|
||||
protected $loggingEnabled = false;
|
||||
|
||||
/**
|
||||
* @var SolrLogManager
|
||||
* @var MeilisearchLogManager
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
@@ -112,7 +112,7 @@ class Indexer extends AbstractIndexer
|
||||
* @param array $options array of indexer options
|
||||
* @param PagesRepository|null $pagesRepository
|
||||
* @param Builder|null $documentBuilder
|
||||
* @param SolrLogManager|null $logger
|
||||
* @param MeilisearchLogManager|null $logger
|
||||
* @param ConnectionManager|null $connectionManager
|
||||
* @param FrontendEnvironment|null $frontendEnvironment
|
||||
*/
|
||||
@@ -120,7 +120,7 @@ class Indexer extends AbstractIndexer
|
||||
array $options = [],
|
||||
PagesRepository $pagesRepository = null,
|
||||
Builder $documentBuilder = null,
|
||||
SolrLogManager $logger = null,
|
||||
MeilisearchLogManager $logger = null,
|
||||
ConnectionManager $connectionManager = null,
|
||||
FrontendEnvironment $frontendEnvironment = null
|
||||
)
|
||||
@@ -128,7 +128,7 @@ class Indexer extends AbstractIndexer
|
||||
$this->options = $options;
|
||||
$this->pagesRepository = $pagesRepository ?? GeneralUtility::makeInstance(PagesRepository::class);
|
||||
$this->documentBuilder = $documentBuilder ?? GeneralUtility::makeInstance(Builder::class);
|
||||
$this->logger = $logger ?? GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->logger = $logger ?? GeneralUtility::makeInstance(MeilisearchLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->connectionManager = $connectionManager ?? GeneralUtility::makeInstance(ConnectionManager::class);
|
||||
$this->frontendEnvironment = $frontendEnvironment ?? GeneralUtility::makeInstance(FrontendEnvironment::class);
|
||||
}
|
||||
@@ -146,9 +146,9 @@ class Indexer extends AbstractIndexer
|
||||
$this->type = $item->getType();
|
||||
$this->setLogging($item);
|
||||
|
||||
$solrConnections = $this->getSolrConnectionsByItem($item);
|
||||
foreach ($solrConnections as $systemLanguageUid => $solrConnection) {
|
||||
$this->solr = $solrConnection;
|
||||
$meilisearchConnections = $this->getMeilisearchConnectionsByItem($item);
|
||||
foreach ($meilisearchConnections as $systemLanguageUid => $meilisearchConnection) {
|
||||
$this->meilisearch = $meilisearchConnection;
|
||||
|
||||
if (!$this->indexItem($item, $systemLanguageUid)) {
|
||||
/*
|
||||
@@ -167,7 +167,7 @@ class Indexer extends AbstractIndexer
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a single Solr Document for an item in a specific language.
|
||||
* Creates a single Meilisearch Document for an item in a specific language.
|
||||
*
|
||||
* @param Item $item An index queue item to index.
|
||||
* @param int $language The language to use.
|
||||
@@ -195,7 +195,7 @@ class Indexer extends AbstractIndexer
|
||||
$documents = $this->preAddModifyDocuments($item, $language, $documents);
|
||||
|
||||
try {
|
||||
$response = $this->solr->getWriteService()->addDocuments($documents);
|
||||
$response = $this->meilisearch->getWriteService()->addDocuments($documents);
|
||||
if ($response->getHttpStatus() == 200) {
|
||||
$itemIndexed = true;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ class Indexer extends AbstractIndexer
|
||||
$itemRecord = $this->getItemRecordOverlayed($item, $language);
|
||||
|
||||
if (!is_null($itemRecord)) {
|
||||
$itemRecord['__solr_index_language'] = $language;
|
||||
$itemRecord['__meilisearch_index_language'] = $language;
|
||||
}
|
||||
|
||||
return $itemRecord;
|
||||
@@ -288,8 +288,8 @@ class Indexer extends AbstractIndexer
|
||||
{
|
||||
try {
|
||||
$pageId = $this->getPageIdOfItem($item);
|
||||
$solrConfiguration = $this->frontendEnvironment->getSolrConfigurationFromPageId($pageId, $language);
|
||||
return $solrConfiguration->getIndexQueueFieldsConfigurationByConfigurationName($indexConfigurationName, []);
|
||||
$meilisearchConfiguration = $this->frontendEnvironment->getMeilisearchConfigurationFromPageId($pageId, $language);
|
||||
return $meilisearchConfiguration->getIndexQueueFieldsConfigurationByConfigurationName($indexConfigurationName, []);
|
||||
} catch (Exception $e) {
|
||||
return [];
|
||||
}
|
||||
@@ -317,9 +317,9 @@ class Indexer extends AbstractIndexer
|
||||
*/
|
||||
protected function getFieldConfigurationFromItemRootPage(Item $item, $language, $indexConfigurationName)
|
||||
{
|
||||
$solrConfiguration = $this->frontendEnvironment->getSolrConfigurationFromPageId($item->getRootPageUid(), $language);
|
||||
$meilisearchConfiguration = $this->frontendEnvironment->getMeilisearchConfigurationFromPageId($item->getRootPageUid(), $language);
|
||||
|
||||
return $solrConfiguration->getIndexQueueFieldsConfigurationByConfigurationName($indexConfigurationName, []);
|
||||
return $meilisearchConfiguration->getIndexQueueFieldsConfigurationByConfigurationName($indexConfigurationName, []);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -343,12 +343,12 @@ class Indexer extends AbstractIndexer
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an item array (record) to a Solr document by mapping the
|
||||
* record's fields onto Solr document fields as configured in TypoScript.
|
||||
* Converts an item array (record) to a Meilisearch document by mapping the
|
||||
* record's fields onto Meilisearch document fields as configured in TypoScript.
|
||||
*
|
||||
* @param Item $item An index queue item
|
||||
* @param int $language Language Id
|
||||
* @return Document|null The Solr document converted from the record
|
||||
* @return Document|null The Meilisearch document converted from the record
|
||||
* @throws SiteNotFoundException
|
||||
* @throws ServiceUnavailableException
|
||||
* @throws ImmediateResponseException
|
||||
@@ -373,11 +373,11 @@ class Indexer extends AbstractIndexer
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Solr document with the basic / core fields set already.
|
||||
* Creates a Meilisearch document with the basic / core fields set already.
|
||||
*
|
||||
* @param Item $item The item to index
|
||||
* @param array $itemRecord The record to use to build the base document
|
||||
* @return Document A basic Solr document
|
||||
* @return Document A basic Meilisearch document
|
||||
*/
|
||||
protected function getBaseDocument(Item $item, array $itemRecord)
|
||||
{
|
||||
@@ -417,14 +417,14 @@ class Indexer extends AbstractIndexer
|
||||
* manipulating fields as defined in the field's configuration.
|
||||
*
|
||||
* @param Item $item An index queue item
|
||||
* @param array $documents An array of \WapplerSystems\Meilisearch\System\Solr\Document\Document objects to manipulate.
|
||||
* @param array $documents An array of \WapplerSystems\Meilisearch\System\Meilisearch\Document\Document objects to manipulate.
|
||||
* @return Document[] array Array of manipulated Document objects.
|
||||
*/
|
||||
protected function processDocuments(Item $item, array $documents)
|
||||
{
|
||||
// needs to respect the TS settings for the page the item is on, conditions may apply
|
||||
$solrConfiguration = $this->frontendEnvironment->getSolrConfigurationFromPageId($item->getRootPageUid());
|
||||
$fieldProcessingInstructions = $solrConfiguration->getIndexFieldProcessingInstructionsConfiguration();
|
||||
$meilisearchConfiguration = $this->frontendEnvironment->getMeilisearchConfigurationFromPageId($item->getRootPageUid());
|
||||
$fieldProcessingInstructions = $meilisearchConfiguration->getIndexFieldProcessingInstructionsConfiguration();
|
||||
|
||||
// same as in the FE indexer
|
||||
if (is_array($fieldProcessingInstructions)) {
|
||||
@@ -448,8 +448,8 @@ class Indexer extends AbstractIndexer
|
||||
{
|
||||
$documents = [];
|
||||
|
||||
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['indexItemAddDocuments'])) {
|
||||
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['indexItemAddDocuments'] as $classReference) {
|
||||
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['IndexQueueIndexer']['indexItemAddDocuments'])) {
|
||||
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['IndexQueueIndexer']['indexItemAddDocuments'] as $classReference) {
|
||||
if (!class_exists($classReference)) {
|
||||
throw new \InvalidArgumentException('Class does not exits' . $classReference, 1490363487);
|
||||
}
|
||||
@@ -474,7 +474,7 @@ class Indexer extends AbstractIndexer
|
||||
|
||||
/**
|
||||
* Provides a hook to manipulate documents right before they get added to
|
||||
* the Solr index.
|
||||
* the Meilisearch index.
|
||||
*
|
||||
* @param Item $item The item currently being indexed.
|
||||
* @param int $language The language uid of the documents
|
||||
@@ -483,8 +483,8 @@ class Indexer extends AbstractIndexer
|
||||
*/
|
||||
protected function preAddModifyDocuments(Item $item, $language, array $documents)
|
||||
{
|
||||
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['preAddModifyDocuments'])) {
|
||||
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['IndexQueueIndexer']['preAddModifyDocuments'] as $classReference) {
|
||||
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['IndexQueueIndexer']['preAddModifyDocuments'])) {
|
||||
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['IndexQueueIndexer']['preAddModifyDocuments'] as $classReference) {
|
||||
$documentsModifier = GeneralUtility::makeInstance($classReference);
|
||||
|
||||
if ($documentsModifier instanceof PageIndexerDocumentsModifier) {
|
||||
@@ -507,17 +507,17 @@ class Indexer extends AbstractIndexer
|
||||
// Initialization
|
||||
|
||||
/**
|
||||
* Gets the Solr connections applicable for an item.
|
||||
* Gets the Meilisearch connections applicable for an item.
|
||||
*
|
||||
* The connections include the default connection and connections to be used
|
||||
* for translations of an item.
|
||||
*
|
||||
* @param Item $item An index queue item
|
||||
* @return array An array of WapplerSystems\Meilisearch\System\Solr\SolrConnection connections, the array's keys are the sys_language_uid of the language of the connection
|
||||
* @return array An array of WapplerSystems\Meilisearch\System\Meilisearch\MeilisearchConnection connections, the array's keys are the sys_language_uid of the language of the connection
|
||||
*/
|
||||
protected function getSolrConnectionsByItem(Item $item)
|
||||
protected function getMeilisearchConnectionsByItem(Item $item)
|
||||
{
|
||||
$solrConnections = [];
|
||||
$meilisearchConnections = [];
|
||||
|
||||
$rootPageId = $item->getRootPageUid();
|
||||
if ($item->getType() === 'pages') {
|
||||
@@ -526,12 +526,12 @@ class Indexer extends AbstractIndexer
|
||||
$pageId = $item->getRecordPageId();
|
||||
}
|
||||
|
||||
// Solr configurations possible for this item
|
||||
// Meilisearch configurations possible for this item
|
||||
$site = $item->getSite();
|
||||
$solrConfigurationsBySite = $site->getAllSolrConnectionConfigurations();
|
||||
$meilisearchConfigurationsBySite = $site->getAllMeilisearchConnectionConfigurations();
|
||||
$siteLanguages = [];
|
||||
foreach ($solrConfigurationsBySite as $solrConfiguration) {
|
||||
$siteLanguages[] = $solrConfiguration['language'];
|
||||
foreach ($meilisearchConfigurationsBySite as $meilisearchConfiguration) {
|
||||
$siteLanguages[] = $meilisearchConfiguration['language'];
|
||||
}
|
||||
|
||||
$defaultLanguageUid = $this->getDefaultLanguageUid($item, $site->getRootPage(), $siteLanguages);
|
||||
@@ -541,13 +541,13 @@ class Indexer extends AbstractIndexer
|
||||
$translationConnections = $this->getConnectionsForIndexableLanguages($translationOverlays);
|
||||
|
||||
if ($defaultLanguageUid == 0) {
|
||||
$solrConnections[0] = $defaultConnection;
|
||||
$meilisearchConnections[0] = $defaultConnection;
|
||||
}
|
||||
|
||||
foreach ($translationConnections as $systemLanguageUid => $solrConnection) {
|
||||
$solrConnections[$systemLanguageUid] = $solrConnection;
|
||||
foreach ($translationConnections as $systemLanguageUid => $meilisearchConnection) {
|
||||
$meilisearchConnections[$systemLanguageUid] = $meilisearchConnection;
|
||||
}
|
||||
return $solrConnections;
|
||||
return $meilisearchConnections;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -641,7 +641,7 @@ class Indexer extends AbstractIndexer
|
||||
* these connections.
|
||||
*
|
||||
* @param array $translationOverlays An array of translation overlays to check for configured connections.
|
||||
* @return array An array of WapplerSystems\Meilisearch\System\Solr\SolrConnection connections.
|
||||
* @return array An array of WapplerSystems\Meilisearch\System\Meilisearch\MeilisearchConnection connections.
|
||||
*/
|
||||
protected function getConnectionsForIndexableLanguages(array $translationOverlays)
|
||||
{
|
||||
@@ -654,7 +654,7 @@ class Indexer extends AbstractIndexer
|
||||
try {
|
||||
$connection = $this->connectionManager->getConnectionByPageId($pageId, $languageId);
|
||||
$connections[$languageId] = $connection;
|
||||
} catch (NoSolrConnectionFoundException $e) {
|
||||
} catch (NoMeilisearchConnectionFoundException $e) {
|
||||
// ignore the exception as we seek only those connections
|
||||
// actually available
|
||||
}
|
||||
@@ -666,7 +666,7 @@ class Indexer extends AbstractIndexer
|
||||
// Utility methods
|
||||
|
||||
// FIXME extract log() and setLogging() to WapplerSystems\Meilisearch\IndexQueue\AbstractIndexer
|
||||
// FIXME extract an interface Tx_Solr_IndexQueue_ItemInterface
|
||||
// FIXME extract an interface Tx_Meilisearch_IndexQueue_ItemInterface
|
||||
|
||||
/**
|
||||
* Enables logging dependent on the configuration of the item's site
|
||||
@@ -676,8 +676,8 @@ class Indexer extends AbstractIndexer
|
||||
*/
|
||||
protected function setLogging(Item $item)
|
||||
{
|
||||
$solrConfiguration = $this->frontendEnvironment->getSolrConfigurationFromPageId($item->getRootPageUid());
|
||||
$this->loggingEnabled = $solrConfiguration->getLoggingIndexingQueueOperationsByConfigurationNameWithFallBack(
|
||||
$meilisearchConfiguration = $this->frontendEnvironment->getMeilisearchConfigurationFromPageId($item->getRootPageUid());
|
||||
$this->loggingEnabled = $meilisearchConfiguration->getLoggingIndexingQueueOperationsByConfigurationNameWithFallBack(
|
||||
$item->getIndexingConfigurationName()
|
||||
);
|
||||
}
|
||||
@@ -686,8 +686,8 @@ class Indexer extends AbstractIndexer
|
||||
* Logs the item and what document was created from it
|
||||
*
|
||||
* @param Item $item The item that is being indexed.
|
||||
* @param array $itemDocuments An array of Solr documents created from the item's data
|
||||
* @param ResponseAdapter $response The Solr response for the particular index document
|
||||
* @param array $itemDocuments An array of Meilisearch documents created from the item's data
|
||||
* @param ResponseAdapter $response The Meilisearch response for the particular index document
|
||||
*/
|
||||
protected function log(Item $item, array $itemDocuments, ResponseAdapter $response)
|
||||
{
|
||||
@@ -706,10 +706,10 @@ class Indexer extends AbstractIndexer
|
||||
$logData = ['item' => (array)$item, 'documents' => $documents, 'response' => (array)$response];
|
||||
|
||||
if ($response->getHttpStatus() == 200) {
|
||||
$severity = SolrLogManager::NOTICE;
|
||||
$severity = MeilisearchLogManager::NOTICE;
|
||||
$message .= 'Success';
|
||||
} else {
|
||||
$severity = SolrLogManager::ERROR;
|
||||
$severity = MeilisearchLogManager::ERROR;
|
||||
$message .= 'Failure';
|
||||
|
||||
$logData['status'] = $response->getHttpStatus();
|
||||
|
@@ -29,7 +29,7 @@ namespace WapplerSystems\Meilisearch\IndexQueue\Initializer;
|
||||
|
||||
use WapplerSystems\Meilisearch\Domain\Index\Queue\QueueItemRepository;
|
||||
use WapplerSystems\Meilisearch\Domain\Site\Site;
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
@@ -81,7 +81,7 @@ abstract class AbstractInitializer implements IndexQueueInitializer
|
||||
protected $flashMessageQueue;
|
||||
|
||||
/**
|
||||
* @var \WapplerSystems\Meilisearch\System\Logging\SolrLogManager
|
||||
* @var \WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
@@ -96,9 +96,9 @@ abstract class AbstractInitializer implements IndexQueueInitializer
|
||||
*/
|
||||
public function __construct(QueueItemRepository $queueItemRepository = null)
|
||||
{
|
||||
$this->logger = GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->logger = GeneralUtility::makeInstance(MeilisearchLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
|
||||
$this->flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier('solr.queue.initializer');
|
||||
$this->flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier('meilisearch.queue.initializer');
|
||||
$this->queueItemRepository = $queueItemRepository ?? GeneralUtility::makeInstance(QueueItemRepository::class);
|
||||
}
|
||||
|
||||
@@ -388,11 +388,11 @@ abstract class AbstractInitializer implements IndexQueueInitializer
|
||||
*/
|
||||
protected function logInitialization(array $logData)
|
||||
{
|
||||
if (!$this->site->getSolrConfiguration()->getLoggingIndexingIndexQueueInitialization()) {
|
||||
if (!$this->site->getMeilisearchConfiguration()->getLoggingIndexingIndexQueueInitialization()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$logSeverity = isset($logData['error']) ? SolrLogManager::ERROR : SolrLogManager::NOTICE;
|
||||
$logSeverity = isset($logData['error']) ? MeilisearchLogManager::ERROR : MeilisearchLogManager::NOTICE;
|
||||
$logData = array_merge($logData, [
|
||||
'site' => $this->site->getLabel(),
|
||||
'indexing configuration name' => $this->indexingConfigurationName,
|
||||
|
@@ -31,7 +31,7 @@ use WapplerSystems\Meilisearch\Domain\Index\Queue\QueueItemRepository;
|
||||
use WapplerSystems\Meilisearch\Domain\Site\SiteRepository;
|
||||
use WapplerSystems\Meilisearch\IndexQueue\Item;
|
||||
use WapplerSystems\Meilisearch\IndexQueue\Queue;
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Records\Pages\PagesRepository;
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
@@ -167,7 +167,7 @@ class Page extends AbstractInitializer
|
||||
$databaseConnection->rollBack();
|
||||
|
||||
$this->logger->log(
|
||||
SolrLogManager::ERROR,
|
||||
MeilisearchLogManager::ERROR,
|
||||
'Index Queue initialization failed for mount pages',
|
||||
[
|
||||
$e->__toString()
|
||||
|
@@ -25,7 +25,7 @@ namespace WapplerSystems\Meilisearch\IndexQueue;
|
||||
***************************************************************/
|
||||
|
||||
/**
|
||||
* Exception that is thrown when trying to add a field to a Solr document using
|
||||
* Exception that is thrown when trying to add a field to a Meilisearch document using
|
||||
* a reserved name.
|
||||
*
|
||||
* @author Ingo Renner <ingo@typo3.org>
|
||||
|
@@ -28,7 +28,7 @@ use WapplerSystems\Meilisearch\Access\Rootline;
|
||||
use WapplerSystems\Meilisearch\Access\RootlineElement;
|
||||
use WapplerSystems\Meilisearch\Domain\Index\PageIndexer\Helper\UriBuilder\AbstractUriStrategy;
|
||||
use WapplerSystems\Meilisearch\Domain\Index\PageIndexer\Helper\UriStrategyFactory;
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
/**
|
||||
@@ -57,8 +57,8 @@ class PageIndexer extends Indexer
|
||||
return false;
|
||||
}
|
||||
|
||||
$solrConnections = $this->getSolrConnectionsByItem($item);
|
||||
foreach ($solrConnections as $systemLanguageUid => $solrConnection) {
|
||||
$meilisearchConnections = $this->getMeilisearchConnectionsByItem($item);
|
||||
foreach ($meilisearchConnections as $systemLanguageUid => $meilisearchConnection) {
|
||||
$contentAccessGroups = $this->getAccessGroupsFromContent($item, $systemLanguageUid);
|
||||
|
||||
if (empty($contentAccessGroups)) {
|
||||
@@ -100,44 +100,44 @@ class PageIndexer extends Indexer
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Solr connections applicable for a page.
|
||||
* Gets the Meilisearch connections applicable for a page.
|
||||
*
|
||||
* The connections include the default connection and connections to be used
|
||||
* for translations of a page.
|
||||
*
|
||||
* @param Item $item An index queue item
|
||||
* @return array An array of WapplerSystems\Meilisearch\System\Solr\SolrConnection connections, the array's keys are the sys_language_uid of the language of the connection
|
||||
* @return array An array of WapplerSystems\Meilisearch\System\Meilisearch\MeilisearchConnection connections, the array's keys are the sys_language_uid of the language of the connection
|
||||
*/
|
||||
protected function getSolrConnectionsByItem(Item $item)
|
||||
protected function getMeilisearchConnectionsByItem(Item $item)
|
||||
{
|
||||
$solrConnections = parent::getSolrConnectionsByItem($item);
|
||||
$meilisearchConnections = parent::getMeilisearchConnectionsByItem($item);
|
||||
|
||||
$page = $item->getRecord();
|
||||
// may use \TYPO3\CMS\Core\Utility\GeneralUtility::hideIfDefaultLanguage($page['l18n_cfg']) with TYPO3 4.6
|
||||
if ($page['l18n_cfg'] & 1) {
|
||||
// page is configured to hide the default translation -> remove Solr connection for default language
|
||||
unset($solrConnections[0]);
|
||||
// page is configured to hide the default translation -> remove Meilisearch connection for default language
|
||||
unset($meilisearchConnections[0]);
|
||||
}
|
||||
|
||||
if (GeneralUtility::hideIfNotTranslated($page['l18n_cfg'])) {
|
||||
$accessibleSolrConnections = [];
|
||||
if (isset($solrConnections[0])) {
|
||||
$accessibleSolrConnections[0] = $solrConnections[0];
|
||||
$accessibleMeilisearchConnections = [];
|
||||
if (isset($meilisearchConnections[0])) {
|
||||
$accessibleMeilisearchConnections[0] = $meilisearchConnections[0];
|
||||
}
|
||||
|
||||
$translationOverlays = $this->pagesRepository->findTranslationOverlaysByPageId((int)$page['uid']);
|
||||
|
||||
foreach ($translationOverlays as $overlay) {
|
||||
$languageId = $overlay['sys_language_uid'];
|
||||
if (array_key_exists($languageId, $solrConnections)) {
|
||||
$accessibleSolrConnections[$languageId] = $solrConnections[$languageId];
|
||||
if (array_key_exists($languageId, $meilisearchConnections)) {
|
||||
$accessibleMeilisearchConnections[$languageId] = $meilisearchConnections[$languageId];
|
||||
}
|
||||
}
|
||||
|
||||
$solrConnections = $accessibleSolrConnections;
|
||||
$meilisearchConnections = $accessibleMeilisearchConnections;
|
||||
}
|
||||
|
||||
return $solrConnections;
|
||||
return $meilisearchConnections;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -169,7 +169,7 @@ class PageIndexer extends Indexer
|
||||
|
||||
if ($this->loggingEnabled) {
|
||||
$this->logger->log(
|
||||
SolrLogManager::INFO,
|
||||
MeilisearchLogManager::INFO,
|
||||
'Page Access Groups',
|
||||
[
|
||||
'item' => (array)$item,
|
||||
@@ -278,7 +278,7 @@ class PageIndexer extends Indexer
|
||||
#
|
||||
|
||||
/**
|
||||
* Creates a single Solr Document for a page in a specific language and for
|
||||
* Creates a single Meilisearch Document for a page in a specific language and for
|
||||
* a specific frontend user group.
|
||||
*
|
||||
* @param Item $item The index queue item representing the page.
|
||||
@@ -300,10 +300,10 @@ class PageIndexer extends Indexer
|
||||
$indexActionResult = $response->getActionResult('indexPage');
|
||||
|
||||
if ($this->loggingEnabled) {
|
||||
$logSeverity = SolrLogManager::INFO;
|
||||
$logSeverity = MeilisearchLogManager::INFO;
|
||||
$logStatus = 'Info';
|
||||
if ($indexActionResult['pageIndexed']) {
|
||||
$logSeverity = SolrLogManager::NOTICE;
|
||||
$logSeverity = MeilisearchLogManager::NOTICE;
|
||||
$logStatus = 'Success';
|
||||
}
|
||||
|
||||
|
@@ -29,7 +29,7 @@ namespace WapplerSystems\Meilisearch\IndexQueue;
|
||||
|
||||
/**
|
||||
* IndexQueuePageIndexerDocumentsModifier interface, allows to modify documents
|
||||
* before adding them to the Solr index in the index queue page indexer.
|
||||
* before adding them to the Meilisearch index in the index queue page indexer.
|
||||
*
|
||||
* @author Ingo Renner <ingo@typo3.org>
|
||||
*/
|
||||
|
@@ -25,7 +25,7 @@ namespace WapplerSystems\Meilisearch\IndexQueue;
|
||||
***************************************************************/
|
||||
|
||||
use WapplerSystems\Meilisearch\System\Configuration\ExtensionConfiguration;
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
@@ -40,7 +40,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
class PageIndexerRequest
|
||||
{
|
||||
|
||||
const SOLR_INDEX_HEADER = 'X-Tx-Solr-Iq';
|
||||
const SOLR_INDEX_HEADER = 'X-Tx-Meilisearch-Iq';
|
||||
|
||||
/**
|
||||
* List of actions to perform during page rendering.
|
||||
@@ -99,7 +99,7 @@ class PageIndexerRequest
|
||||
protected $timeout;
|
||||
|
||||
/**
|
||||
* @var \WapplerSystems\Meilisearch\System\Logging\SolrLogManager
|
||||
* @var \WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
@@ -117,16 +117,16 @@ class PageIndexerRequest
|
||||
* PageIndexerRequest constructor.
|
||||
*
|
||||
* @param string $jsonEncodedParameters json encoded header
|
||||
* @param SolrLogManager|null $solrLogManager
|
||||
* @param MeilisearchLogManager|null $meilisearchLogManager
|
||||
* @param ExtensionConfiguration|null $extensionConfiguration
|
||||
* @param RequestFactory|null $requestFactory
|
||||
*/
|
||||
public function __construct($jsonEncodedParameters = null, SolrLogManager $solrLogManager = null, ExtensionConfiguration $extensionConfiguration = null, RequestFactory $requestFactory = null)
|
||||
public function __construct($jsonEncodedParameters = null, MeilisearchLogManager $meilisearchLogManager = null, ExtensionConfiguration $extensionConfiguration = null, RequestFactory $requestFactory = null)
|
||||
{
|
||||
$this->requestId = uniqid();
|
||||
$this->timeout = (float)ini_get('default_socket_timeout');
|
||||
|
||||
$this->logger = $solrLogManager ?? GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->logger = $meilisearchLogManager ?? GeneralUtility::makeInstance(MeilisearchLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->extensionConfiguration = $extensionConfiguration ?? GeneralUtility::makeInstance(ExtensionConfiguration::class);
|
||||
$this->requestFactory = $requestFactory ?? GeneralUtility::makeInstance(RequestFactory::class);
|
||||
|
||||
@@ -207,7 +207,7 @@ class PageIndexerRequest
|
||||
|
||||
if ($rawResponse === false || $decodedResponse === false) {
|
||||
$this->logger->log(
|
||||
SolrLogManager::ERROR,
|
||||
MeilisearchLogManager::ERROR,
|
||||
'Failed to execute Page Indexer Request. Request ID: ' . $this->requestId,
|
||||
[
|
||||
'request ID' => $this->requestId,
|
||||
|
@@ -33,7 +33,7 @@ use WapplerSystems\Meilisearch\Domain\Index\Queue\Statistic\QueueStatisticsRepos
|
||||
use WapplerSystems\Meilisearch\Domain\Site\Site;
|
||||
use WapplerSystems\Meilisearch\FrontendEnvironment;
|
||||
use WapplerSystems\Meilisearch\System\Cache\TwoLevelCache;
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
|
||||
@@ -56,7 +56,7 @@ class Queue
|
||||
protected $recordService;
|
||||
|
||||
/**
|
||||
* @var \WapplerSystems\Meilisearch\System\Logging\SolrLogManager
|
||||
* @var \WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
@@ -97,7 +97,7 @@ class Queue
|
||||
FrontendEnvironment $frontendEnvironment = null
|
||||
)
|
||||
{
|
||||
$this->logger = GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->logger = GeneralUtility::makeInstance(MeilisearchLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->rootPageResolver = $rootPageResolver ?? GeneralUtility::makeInstance(RootPageResolver::class);
|
||||
$this->recordService = $recordService ?? GeneralUtility::makeInstance(ConfigurationAwareRecordService::class);
|
||||
$this->queueItemRepository = $queueItemRepository ?? GeneralUtility::makeInstance(QueueItemRepository::class);
|
||||
@@ -159,7 +159,7 @@ class Queue
|
||||
/**
|
||||
* Marks an item as needing (re)indexing.
|
||||
*
|
||||
* Like with Solr itself, there's no add method, just a simple update method
|
||||
* Like with Meilisearch itself, there's no add method, just a simple update method
|
||||
* that handles the adds, too.
|
||||
*
|
||||
* The method creates or updates the index queue items for all related rootPageIds.
|
||||
@@ -195,8 +195,8 @@ class Queue
|
||||
continue;
|
||||
}
|
||||
|
||||
$solrConfiguration = $this->frontendEnvironment->getSolrConfigurationFromPageId($rootPageId);
|
||||
$indexingConfiguration = $this->recordService->getIndexingConfigurationName($itemType, $itemUid, $solrConfiguration);
|
||||
$meilisearchConfiguration = $this->frontendEnvironment->getMeilisearchConfigurationFromPageId($rootPageId);
|
||||
$indexingConfiguration = $this->recordService->getIndexingConfigurationName($itemType, $itemUid, $meilisearchConfiguration);
|
||||
if ($indexingConfiguration === null) {
|
||||
continue;
|
||||
}
|
||||
@@ -227,11 +227,11 @@ class Queue
|
||||
*/
|
||||
protected function postProcessIndexQueueUpdateItem($itemType, $itemUid, $updateCount, $forcedChangeTime = 0)
|
||||
{
|
||||
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['postProcessIndexQueueUpdateItem'])) {
|
||||
if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['postProcessIndexQueueUpdateItem'])) {
|
||||
return $updateCount;
|
||||
}
|
||||
|
||||
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['solr']['postProcessIndexQueueUpdateItem'] as $classReference) {
|
||||
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['meilisearch']['postProcessIndexQueueUpdateItem'] as $classReference) {
|
||||
$updateHandler = $this->getHookImplementation($classReference);
|
||||
$updateCount = $updateHandler->postProcessIndexQueueUpdateItem($itemType, $itemUid, $updateCount, $forcedChangeTime);
|
||||
}
|
||||
@@ -568,7 +568,7 @@ class Queue
|
||||
*
|
||||
* @param Site $site TYPO3 site
|
||||
* @param int $limit Number of items to get from the queue
|
||||
* @return Item[] Items to index to the given solr server
|
||||
* @return Item[] Items to index to the given meilisearch server
|
||||
*/
|
||||
public function getItemsToIndex(Site $site, $limit = 50)
|
||||
{
|
||||
|
@@ -32,7 +32,7 @@ use WapplerSystems\Meilisearch\FrontendEnvironment;
|
||||
use WapplerSystems\Meilisearch\GarbageCollector;
|
||||
use WapplerSystems\Meilisearch\System\Configuration\ExtensionConfiguration;
|
||||
use WapplerSystems\Meilisearch\System\Configuration\TypoScriptConfiguration;
|
||||
use WapplerSystems\Meilisearch\System\Logging\SolrLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Logging\MeilisearchLogManager;
|
||||
use WapplerSystems\Meilisearch\System\Records\Pages\PagesRepository;
|
||||
use WapplerSystems\Meilisearch\System\TCA\TCAService;
|
||||
use WapplerSystems\Meilisearch\Util;
|
||||
@@ -83,7 +83,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
protected $pagesRepository;
|
||||
|
||||
/**
|
||||
* @var SolrLogManager
|
||||
* @var MeilisearchLogManager
|
||||
*/
|
||||
protected $logger = null;
|
||||
|
||||
@@ -100,7 +100,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
* @param TCAService|null $TCAService
|
||||
* @param RootPageResolver $rootPageResolver
|
||||
* @param PagesRepository|null $pagesRepository
|
||||
* @param SolrLogManager|null $solrLogManager
|
||||
* @param MeilisearchLogManager|null $meilisearchLogManager
|
||||
* @param ConfigurationAwareRecordService|null $recordService
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -109,7 +109,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
TCAService $TCAService = null,
|
||||
RootPageResolver $rootPageResolver = null,
|
||||
PagesRepository $pagesRepository = null,
|
||||
SolrLogManager $solrLogManager = null,
|
||||
MeilisearchLogManager $meilisearchLogManager = null,
|
||||
ConfigurationAwareRecordService $recordService = null,
|
||||
FrontendEnvironment $frontendEnvironment = null
|
||||
)
|
||||
@@ -120,14 +120,14 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
$this->tcaService = $TCAService ?? GeneralUtility::makeInstance(TCAService::class);
|
||||
$this->rootPageResolver = $rootPageResolver ?? GeneralUtility::makeInstance(RootPageResolver::class);
|
||||
$this->pagesRepository = $pagesRepository ?? GeneralUtility::makeInstance(PagesRepository::class);
|
||||
$this->logger = $solrLogManager ?? GeneralUtility::makeInstance(SolrLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->logger = $meilisearchLogManager ?? GeneralUtility::makeInstance(MeilisearchLogManager::class, /** @scrutinizer ignore-type */ __CLASS__);
|
||||
$this->frontendEnvironment = $frontendEnvironment ?? GeneralUtility::makeInstance(FrontendEnvironment::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SolrLogManager $logger
|
||||
* @param MeilisearchLogManager $logger
|
||||
*/
|
||||
public function setLogger(SolrLogManager $logger)
|
||||
public function setLogger(MeilisearchLogManager $logger)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
@@ -248,8 +248,8 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
*/
|
||||
protected function applyPageChangesToQueue($uid)
|
||||
{
|
||||
$solrConfiguration = $this->getSolrConfigurationFromPageId($uid);
|
||||
$record = $this->configurationAwareRecordService->getRecord('pages', $uid, $solrConfiguration);
|
||||
$meilisearchConfiguration = $this->getMeilisearchConfigurationFromPageId($uid);
|
||||
$record = $this->configurationAwareRecordService->getRecord('pages', $uid, $meilisearchConfiguration);
|
||||
if (!empty($record) && $this->tcaService->isEnabledRecord('pages', $record)) {
|
||||
$this->mountPageUpdater->update($uid);
|
||||
$this->indexQueue->updateItem('pages', $uid);
|
||||
@@ -268,11 +268,11 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
*/
|
||||
protected function applyRecordChangesToQueue($table, $uid, $pid)
|
||||
{
|
||||
$solrConfiguration = $this->getSolrConfigurationFromPageId($pid);
|
||||
$isMonitoredTable = $solrConfiguration->getIndexQueueIsMonitoredTable($table);
|
||||
$meilisearchConfiguration = $this->getMeilisearchConfigurationFromPageId($pid);
|
||||
$isMonitoredTable = $meilisearchConfiguration->getIndexQueueIsMonitoredTable($table);
|
||||
|
||||
if ($isMonitoredTable) {
|
||||
$record = $this->configurationAwareRecordService->getRecord($table, $uid, $solrConfiguration);
|
||||
$record = $this->configurationAwareRecordService->getRecord($table, $uid, $meilisearchConfiguration);
|
||||
|
||||
if (!empty($record) && $this->tcaService->isEnabledRecord($table, $record)) {
|
||||
$uid = $this->tcaService->getTranslationOriginalUidIfTranslated($table, $record, $uid);
|
||||
@@ -287,7 +287,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
/**
|
||||
* Hooks into TCE Main and watches all record creations and updates. If it
|
||||
* detects that the new/updated record belongs to a table configured for
|
||||
* indexing through Solr, we add the record to the index queue.
|
||||
* indexing through Meilisearch, we add the record to the index queue.
|
||||
*
|
||||
* @param string $status Status of the current operation, 'new' or 'update'
|
||||
* @param string $table The table the record belongs to
|
||||
@@ -324,7 +324,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
$this->processRecord($recordTable, $recordPageId, $recordUid, $fields);
|
||||
} catch (NoPidException $e) {
|
||||
$message = 'Record without valid pid was processed ' . $table . ':' . $uid;
|
||||
$this->logger->log(SolrLogManager::WARNING, $message);
|
||||
$this->logger->log(MeilisearchLogManager::WARNING, $message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,14 +380,14 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
}
|
||||
}
|
||||
foreach ($rootPageIds as $configurationPageId) {
|
||||
$solrConfiguration = $this->getSolrConfigurationFromPageId($configurationPageId);
|
||||
$isMonitoredRecord = $solrConfiguration->getIndexQueueIsMonitoredTable($recordTable);
|
||||
$meilisearchConfiguration = $this->getMeilisearchConfigurationFromPageId($configurationPageId);
|
||||
$isMonitoredRecord = $meilisearchConfiguration->getIndexQueueIsMonitoredTable($recordTable);
|
||||
if (!$isMonitoredRecord) {
|
||||
// when it is a non monitored record, we can skip it.
|
||||
continue;
|
||||
}
|
||||
|
||||
$record = $this->configurationAwareRecordService->getRecord($recordTable, $recordUid, $solrConfiguration);
|
||||
$record = $this->configurationAwareRecordService->getRecord($recordTable, $recordUid, $meilisearchConfiguration);
|
||||
if (empty($record)) {
|
||||
// TODO move this part to the garbage collector
|
||||
// check if the item should be removed from the index because it no longer matches the conditions
|
||||
@@ -514,7 +514,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes record from the index queue and from the solr index
|
||||
* Removes record from the index queue and from the meilisearch index
|
||||
*
|
||||
* @param string $recordTable Name of table where the record lives
|
||||
* @param int $recordUid Id of record
|
||||
@@ -526,7 +526,7 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes record from the index queue and from the solr index when the item is in the queue.
|
||||
* Removes record from the index queue and from the meilisearch index when the item is in the queue.
|
||||
*
|
||||
* @param string $recordTable Name of table where the record lives
|
||||
* @param int $recordUid Id of record
|
||||
@@ -594,8 +594,8 @@ class RecordMonitor extends AbstractDataHandlerListener
|
||||
* @param int $language
|
||||
* @return TypoScriptConfiguration
|
||||
*/
|
||||
protected function getSolrConfigurationFromPageId($pageId)
|
||||
protected function getMeilisearchConfigurationFromPageId($pageId)
|
||||
{
|
||||
return $this->frontendEnvironment->getSolrConfigurationFromPageId($pageId);
|
||||
return $this->frontendEnvironment->getMeilisearchConfigurationFromPageId($pageId);
|
||||
}
|
||||
}
|
||||
|
@@ -41,11 +41,11 @@ interface SerializedValueDetector
|
||||
* unserialized.
|
||||
*
|
||||
* @param array $indexingConfiguration Current item's indexing configuration
|
||||
* @param string $solrFieldName Current field being indexed
|
||||
* @param string $meilisearchFieldName Current field being indexed
|
||||
* @return bool TRUE if the value is expected to be serialized, FALSE otherwise
|
||||
*/
|
||||
public function isSerializedValue(
|
||||
array $indexingConfiguration,
|
||||
$solrFieldName
|
||||
$meilisearchFieldName
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user