Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions Classes/Controller/AbstractBaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use ApacheSolrForTypo3\Solr\Domain\Search\SearchRequestBuilder;
use ApacheSolrForTypo3\Solr\NoSolrConnectionFoundException;
use ApacheSolrForTypo3\Solr\Search;
use ApacheSolrForTypo3\Solr\System\Configuration\ConfigurationManager as SolrConfigurationManager;
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
use ApacheSolrForTypo3\Solr\System\Logging\SolrLogManager;
use ApacheSolrForTypo3\Solr\System\Service\ConfigurationService;
Expand All @@ -43,10 +42,8 @@ abstract class AbstractBaseController extends ActionController

private ?ContentObjectRenderer $contentObjectRenderer = null;

private ?SolrConfigurationManager $solrConfigurationManager = null;

/**
* The configuration is private if you need it please get it from the SolrVariableProvider of RenderingContext.
* The configuration is private if you need it, please get it from the SolrVariableProvider of RenderingContext.
*/
protected ?TypoScriptConfiguration $typoScriptConfiguration = null;

Expand All @@ -72,11 +69,6 @@ public function getContentObjectRenderer(): ?ContentObjectRenderer
return $this->contentObjectRenderer;
}

public function injectSolrConfigurationManager(SolrConfigurationManager $configurationManager): void
{
$this->solrConfigurationManager = $configurationManager;
}

public function setResetConfigurationBeforeInitialize(bool $resetConfigurationBeforeInitialize): void
{
$this->resetConfigurationBeforeInitialize = $resetConfigurationBeforeInitialize;
Expand All @@ -91,7 +83,7 @@ protected function initializeAction(): void
/** @var TypoScriptService $typoScriptService */
$typoScriptService = GeneralUtility::makeInstance(TypoScriptService::class);

// Merge settings done by typoscript with solrConfiguration plugin.tx_solr (obsolete when part of ext:solr)
// Merge settings done by TypoScript with solrConfiguration plugin.tx_solr (obsolete when part of ext:solr)
$frameWorkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
$pluginSettings = [];
foreach (['search', 'settings', 'suggest', 'statistics', 'logging', 'general', 'solr', 'view'] as $key) {
Expand All @@ -100,7 +92,11 @@ protected function initializeAction(): void
}
}

$this->typoScriptConfiguration = $this->solrConfigurationManager->getTypoScriptFromRequest($this->request);
$this->typoScriptConfiguration = GeneralUtility::makeInstance(
TypoScriptConfiguration::class,
$this->request->getAttribute('frontend.typoscript')->getSetupArray(),
$this->request->getAttribute('routing')->getPageId(),
);
if ($pluginSettings !== []) {
$this->typoScriptConfiguration->mergeSolrConfiguration(
$typoScriptService->convertPlainArrayToTypoScriptArray($pluginSettings),
Expand Down
10 changes: 10 additions & 0 deletions Classes/FrontendEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

use ApacheSolrForTypo3\Solr\System\Configuration\ConfigurationManager;
use ApacheSolrForTypo3\Solr\System\Configuration\TypoScriptConfiguration;
use Doctrine\DBAL\Exception as DBALException;
use JsonException;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
use TYPO3\CMS\Core\Exception\SiteNotFoundException;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -37,6 +40,9 @@ class FrontendEnvironment implements SingletonInterface
* Check whether the page record is within the configured allowed pages types(doktype) for indexing.
* Uses TypoScript: plugin.tx_solr.index.queue.<queue name>.allowedPageTypes
*
* @throws DBALException
* @throws JsonException
* @throws NoSuchCacheException
* @throws SiteNotFoundException
*/
public function isAllowedPageType(
Expand Down Expand Up @@ -74,6 +80,10 @@ public function isAllowedPageType(
/**
* Returns TypoScriptConfiguration for desired page ID and language id.
*
*
* @throws DBALException
* @throws JsonException
* @throws NoSuchCacheException
* @throws SiteNotFoundException
*
* @todo: check when to use $rootPageId and if it can be removed.
Expand Down
15 changes: 10 additions & 5 deletions Classes/FrontendEnvironment/Tsfe.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use ApacheSolrForTypo3\Solr\System\Configuration\ConfigurationManager;
use ApacheSolrForTypo3\Solr\System\Configuration\ConfigurationPageResolver;
use Doctrine\DBAL\Exception as DBALException;
use JsonException;
use Throwable;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Context\Context;
Expand Down Expand Up @@ -66,12 +67,11 @@ public function __construct(?SiteFinder $siteFinder = null)
/**
* Initializes the TSFE for a given page ID and language.
*
*
*
* @throws AspectNotFoundException
* @throws DBALException
* @throws Exception\Exception
* @throws SiteNotFoundException
* @throws DBALException
*
* @throws JsonException
*
* @todo: Move whole caching stuff from this method and let return TSFE.
*/
Expand Down Expand Up @@ -179,6 +179,8 @@ protected function initializeTsfe(int $pageId, int $language = 0, ?int $rootPage
* @throws SiteNotFoundException
* @throws Exception\Exception
* @throws DBALException
* @throws JsonException
* @throws AspectNotFoundException
*/
public function getTsfeByPageIdAndLanguageId(int $pageId, int $language = 0, ?int $rootPageId = null): ?TypoScriptFrontendController
{
Expand Down Expand Up @@ -241,6 +243,8 @@ public function getTsfeByPageIdIgnoringLanguage(int $pageId): ?TypoScriptFronten
* @throws SiteNotFoundException
* @throws Exception\Exception
* @throws DBALException
* @throws JsonException
* @throws AspectNotFoundException
*
* @noinspection PhpUnused
*/
Expand All @@ -258,13 +262,14 @@ public function getServerRequestForTsfeByPageIdAndLanguageId(int $pageId, int $l
* @throws SiteNotFoundException
* @throws Exception\Exception
* @throws DBALException
* @throws JsonException
* @throws AspectNotFoundException
*/
protected function assureIsInitialized(int $pageId, int $language, ?int $rootPageId = null): void
{
$cacheIdentifier = $this->getCacheIdentifier($pageId, $language, $rootPageId);
if (!array_key_exists($cacheIdentifier, $this->tsfeCache)) {
$this->initializeTsfe($pageId, $language, $rootPageId);
return;
}
}

Expand Down
26 changes: 25 additions & 1 deletion Classes/System/Configuration/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
use Psr\Container\ContainerInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ServerRequestInterface;
use RuntimeException;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Context\VisibilityAspect;
use TYPO3\CMS\Core\Database\ConnectionPool;
Expand Down Expand Up @@ -50,6 +53,7 @@ class ConfigurationManager implements SingletonInterface
/**
* @throws DBALException
* @throws JsonException
* @throws NoSuchCacheException
*/
public function getTypoScriptFromRequest(ServerRequestInterface $request): TypoScriptConfiguration
{
Expand All @@ -68,7 +72,22 @@ public function getTypoScriptFromRequest(ServerRequestInterface $request): TypoS
}
}
}
$fullConfig = $this->getCoreTypoScriptFrontendByRequest($request)->getSetupArray();
try {
$fullConfig = $request->getAttribute('frontend.typoscript')?->getSetupArray();
} catch (RuntimeException) {
$fullConfig = null;
}
if ($fullConfig === null) {
$cache = GeneralUtility::makeInstance(CacheManager::class)->getCache('hash');
$cacheIdentifier = $pageId . '_' . ($request->getAttribute('language')?->getLanguageId() ?? 0);
if (!$cache->has($cacheIdentifier)) {
// Fallback to full TypoScript configuration
$fullConfig = $this->getCoreTypoScriptFrontendByRequest($request)->getSetupArray();
$cache->set($cacheIdentifier, $fullConfig);
} else {
$fullConfig = $cache->get($cacheIdentifier);
}
}
return GeneralUtility::makeInstance(TypoScriptConfiguration::class, $fullConfig, $pageId);
}

Expand All @@ -79,6 +98,7 @@ public function getTypoScriptFromRequest(ServerRequestInterface $request): TypoS
* @throws DBALException
* @throws JsonException
* @throws SiteNotFoundException
* @throws NoSuchCacheException
*/
public function getTypoScriptConfiguration(?int $contextPageId = null, int $contextLanguageId = 0): TypoScriptConfiguration
{
Expand Down Expand Up @@ -129,6 +149,10 @@ public function getTypoScriptConfiguration(?int $contextPageId = null, int $cont
*/
public function getCoreTypoScriptFrontendByRequest(ServerRequestInterface $request): FrontendTypoScript
{
if ($request->getAttribute('frontend.typoscript') instanceof FrontendTypoScript) {
return $request->getAttribute('frontend.typoscript');
}

$typo3Site = $request->getAttribute('site');
$sysTemplateRows = $this->getSysTemplateRowsForAssociatedContextPageId($request);

Expand Down