diff --git a/Classes/Routing/Enhancer/SolrFacetMaskAndCombineEnhancer.php b/Classes/Routing/Enhancer/SolrFacetMaskAndCombineEnhancer.php index b19a18bf26..e206304271 100644 --- a/Classes/Routing/Enhancer/SolrFacetMaskAndCombineEnhancer.php +++ b/Classes/Routing/Enhancer/SolrFacetMaskAndCombineEnhancer.php @@ -16,6 +16,8 @@ namespace ApacheSolrForTypo3\Solr\Routing\Enhancer; use ApacheSolrForTypo3\Solr\Routing\RoutingService; +use ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration; +use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager; use ApacheSolrForTypo3\Solr\Utility\RoutingUtility; use TYPO3\CMS\Core\Routing\Enhancer\AbstractEnhancer; use TYPO3\CMS\Core\Routing\Enhancer\RoutingEnhancerInterface; @@ -25,6 +27,7 @@ class SolrFacetMaskAndCombineEnhancer extends AbstractEnhancer implements RoutingEnhancerInterface, SolrRouteEnhancerInterface { + protected bool $isEnabled; protected array $configuration; protected string $namespace; @@ -33,6 +36,9 @@ public function __construct(array $configuration) { $this->configuration = $configuration; $this->namespace = $this->configuration['extensionKey'] ?? 'tx_solr'; + + $extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class); + $this->isEnabled = $extensionConfiguration->getIsRouteEnhancerEnabled(); } /** @@ -40,6 +46,15 @@ public function __construct(array $configuration) */ public function enhanceForMatching(RouteCollection $collection): void { + if (!$this->isEnabled) { + $logger = GeneralUtility::makeInstance(SolrLogManager::class, __CLASS__); + $logger->error( + 'Solr routing enhancer deactivated in Solr configuration,' + . ' set enableRouteEnhancer or remove SolrFacetMaskAndCombineEnhancer' + ); + return; + } + /** @var Route $defaultPageRoute */ $defaultPageRoute = $collection->get('default'); $variant = $this->getVariant($defaultPageRoute, $this->configuration); @@ -79,8 +94,8 @@ protected function getVariant(Route $defaultPageRoute, array $configuration): Ro */ public function enhanceForGeneration(RouteCollection $collection, array $parameters): void { - // No parameter for this namespace given, so this route does not fit the requirements - if (!is_array($parameters[$this->namespace] ?? null)) { + // Disabled or no parameter for this namespace given, so this route does not fit the requirements + if (!$this->isEnabled || !is_array($parameters[$this->namespace] ?? null)) { return; } /** @var Route $defaultPageRoute */ diff --git a/Classes/System/Configuration/ExtensionConfiguration.php b/Classes/System/Configuration/ExtensionConfiguration.php index 0c0240b41d..fca5331c98 100644 --- a/Classes/System/Configuration/ExtensionConfiguration.php +++ b/Classes/System/Configuration/ExtensionConfiguration.php @@ -151,6 +151,14 @@ public function getMonitoringType(): int return (int)$this->getConfigurationOrDefaultValue('monitoringType', 0); } + /** + * Get configuration for enableRouteEnhancer + */ + public function getIsRouteEnhancerEnabled(): bool + { + return (bool)$this->getConfigurationOrDefaultValue('enableRouteEnhancer', false); + } + protected function getConfigurationOrDefaultValue(string $key, mixed $defaultValue = null): mixed { return $this->configuration[$key] ?? $defaultValue; diff --git a/Configuration/RequestMiddlewares.php b/Configuration/RequestMiddlewares.php index f40b9be8a5..4065d85809 100644 --- a/Configuration/RequestMiddlewares.php +++ b/Configuration/RequestMiddlewares.php @@ -1,18 +1,26 @@ [ - 'apache-solr-for-typo3/page-indexer-initialization' => [ - 'target' => \ApacheSolrForTypo3\Solr\Middleware\PageIndexerInitialization::class, - 'before' => ['typo3/cms-frontend/tsfe'], - 'after' => ['typo3/cms-core/normalized-params-attribute'], - ], - 'apache-solr-for-typo3/solr-route-enhancer' => [ - 'target' => \ApacheSolrForTypo3\Solr\Middleware\SolrRoutingMiddleware::class, - 'before' => [ - 'typo3/cms-frontend/site', - ], - ], +$requestMiddlewares = [ + 'apache-solr-for-typo3/page-indexer-initialization' => [ + 'target' => \ApacheSolrForTypo3\Solr\Middleware\PageIndexerInitialization::class, + 'before' => ['typo3/cms-frontend/tsfe'], + 'after' => ['typo3/cms-core/normalized-params-attribute'], ], ]; + +$extensionConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( + \ApacheSolrForTypo3\Solr\System\Configuration\ExtensionConfiguration::class +); +if ($extensionConfiguration->getIsRouteEnhancerEnabled()) { + $requestMiddlewares['apache-solr-for-typo3/solr-route-enhancer'] = [ + 'target' => \ApacheSolrForTypo3\Solr\Middleware\SolrRoutingMiddleware::class, + 'before' => [ + 'typo3/cms-frontend/site', + ], + ]; +} + +return [ + 'frontend' => $requestMiddlewares, +]; diff --git a/Documentation/Releases/solr-release-12-0.rst b/Documentation/Releases/solr-release-12-0.rst index b148823a12..85c32b3bcd 100644 --- a/Documentation/Releases/solr-release-12-0.rst +++ b/Documentation/Releases/solr-release-12-0.rst @@ -154,11 +154,22 @@ If you've used this class or the SolrConnection directly, you have to adapt your - use \Solarium\Core\Client\Endpoint instead of \ApacheSolrForTypo3\Solr\System\Solr\Node - call \ApacheSolrForTypo3\Solr\System\Solr\SolrConnection->getEndpoint() instead of \ApacheSolrForTypo3\Solr\System\Solr\SolrConnection\getNode(), method will return Solarium Endpoint -- Node could be converted to string to get the core base URI, getCoreBaseUri() can be used instead. +- Node could be converted to string to get the core base URI, getCoreBaseUri() can be used instead. Note: With dropping the Node implementation we also dropped the backwards compatibility that allows to define the Solr path segment "/solr" within "solr_path_read" or "solr_path_write". Be sure your configuration doesn't contain this path segment! +!!! Solr route enhancer disabled by default +------------------------------------------- + +EXT:solr offers the possibility to create speaking URLs for Solr facets, but as this feature requires additional configuration and costly processing this feature is now disabled by default. + +If you've already used the route enhancer you must set option "enableRouteEnhancer": + +:php:`$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['solr']['enableRouteEnhancer']` + + + Frontend Helper Changes ----------------------- diff --git a/Resources/Private/Language/locallang_be.xlf b/Resources/Private/Language/locallang_be.xlf index 5f19fec7be..7de815bb37 100644 --- a/Resources/Private/Language/locallang_be.xlf +++ b/Resources/Private/Language/locallang_be.xlf @@ -3,6 +3,9 @@
+ + Route Enhancer + Monitoring: Define how data updates should be monitored @@ -15,6 +18,9 @@ No monitoring at all + + Enable route enhancer: If you want to use speaking URLs for Solr facets, you have to enable this option, otherwise the required Middleware is not active and the route enhancer has no effect. + Event Queue Worker diff --git a/ext_conf_template.txt b/ext_conf_template.txt index 41f54d5025..2ca452a241 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -1,3 +1,5 @@ +# customcategory=Routes=LLL:EXT:solr/Resources/Private/Language/locallang_be.xlf:extConf.category.routeEnhancer + # cat=basic/enable/8; type=string; label=A list of white listed plugin namespaces (Required by cacheHash/excludedParameters and plugin flex form): Note: This list only is available in Plugin -> Options -> Plugin Namespace pluginNamespaces = tx_solr @@ -17,4 +19,7 @@ useConfigurationMonitorTables = allowSelfSignedCertificates = 0 # cat=basic/enable/50; type=options[LLL:EXT:solr/Resources/Private/Language/locallang_be.xlf:extConf.monitoringType.I.0=0,LLL:EXT:solr/Resources/Private/Language/locallang_be.xlf:extConf.monitoringType.I.1=1,LLL:EXT:solr/Resources/Private/Language/locallang_be.xlf:extConf.monitoringType.I.2=2]; label=LLL:EXT:solr/Resources/Private/Language/locallang_be.xlf:extConf.monitoringType -monitoringType = 0 \ No newline at end of file +monitoringType = 0 + +# cat=Routes/enable/10; type=boolean; label=LLL:EXT:solr/Resources/Private/Language/locallang_be.xlf:extConf.enableRouteEnhancer +enableRouteEnhancer = 0 \ No newline at end of file