Skip to content

Commit

Permalink
[TASK:T12] Migrate Page indexing stack to TYPO3 12+ API :: Core #98303
Browse files Browse the repository at this point in the history
This change contains chenges for indexing stack related to TYPO3 Core BC #98303
[!!!][FEATURE] Add generic language overlay PSR-14 events instead of hooks

Fixes: #3529
Relates: #3376
  • Loading branch information
dkd-kaehm committed May 15, 2023
1 parent d3867e1 commit eadcb96
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 112 deletions.
1 change: 0 additions & 1 deletion Classes/IndexQueue/FrontendHelper/PageIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Doctrine\DBAL\Exception as DBALException;
use Throwable;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
Expand Down
49 changes: 20 additions & 29 deletions Classes/System/Language/FrontendOverlayService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
use Doctrine\DBAL\Exception as DBALException;
use TYPO3\CMS\Core\Context\Exception\AspectNotFoundException;
use TYPO3\CMS\Core\Context\LanguageAspect;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -32,44 +33,33 @@
class FrontendOverlayService
{
/**
* @var TCAService
* FrontendOverlayService constructor
*/
protected $tcaService;

/**
* @var TypoScriptFrontendController|null
*/
protected ?TypoScriptFrontendController $tsfe = null;

/**
* Relation constructor.
* @param TCAService|null $tcaService
* @param TypoScriptFrontendController|null $tsfe
*/
public function __construct(TCAService $tcaService = null, TypoScriptFrontendController $tsfe = null)
{
$this->tcaService = $tcaService ?? GeneralUtility::makeInstance(TCAService::class);
$this->tsfe = $tsfe;
public function __construct(
protected readonly TCAService $tcaService,
protected readonly TypoScriptFrontendController $tsfe
) {
}

/**
* Return the translated record
*
* @param string $tableName
* @param array $record
* @return array
*
* @return array|null
*
* @throws AspectNotFoundException
*/
public function getOverlay(string $tableName, array $record): ?array
{
$currentLanguageUid = $this->tsfe->getContext()->getPropertyFromAspect('language', 'id');
if ($tableName === 'pages') {
// @extensionScannerIgnoreLine
return $this->tsfe->sys_page->getPageOverlay($record, $currentLanguageUid);
}
/* @var LanguageAspect $currentLanguageAspect */
$currentLanguageAspect = $this->tsfe->getContext()->getAspect('language');
// if ($tableName === 'pages') {
// return $this->tsfe->sys_page->getPageOverlay($record, $currentLanguageAspect);
// }

// @extensionScannerIgnoreLine
return $this->tsfe->sys_page->getRecordOverlay($tableName, $record, $currentLanguageUid);
return $this->tsfe->sys_page->getLanguageOverlay($tableName, $record, $currentLanguageAspect);
}

/**
Expand Down Expand Up @@ -136,11 +126,12 @@ protected function getLocalRecordUidFromOverlay(string $localTableName, array $o
/**
* @param string $localTableName
* @param int $localRecordUid
* @return mixed
* @throws DBALDriverException
* @throws DBALException|\Doctrine\DBAL\DBALException
*
* @return array<string,mixed>|false
*
* @throws DBALException
*/
protected function getRecord(string $localTableName, int $localRecordUid)
protected function getRecord(string $localTableName, int $localRecordUid): array|false
{
/* @var QueryBuilder $queryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($localTableName);
Expand Down
5 changes: 3 additions & 2 deletions Tests/Integration/Backend/SettingsPreviewOnPluginsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\CMS\Backend\View\Event\PageContentPreviewRenderingEvent;
use TYPO3\CMS\Backend\View\PageLayoutContext;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\Service\FlexFormService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* EXT:solr offers a summary in the BE on search plugins, that summarizes the extension
Expand Down Expand Up @@ -57,8 +58,8 @@ class SettingsPreviewOnPluginsTest extends IntegrationTest

protected function setUp(): void
{
$GLOBALS['LANG'] = $this->createMock(LanguageService::class);
parent::setUp();
$GLOBALS['LANG'] = $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTest;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\Messaging\AbstractMessage;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -42,7 +42,7 @@ class IndexAdministrationModuleControllerTest extends IntegrationTest
protected function setUp(): void
{
parent::setUp();
$GLOBALS['LANG'] = $this->createMock(LanguageService::class);
$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create('default');

$this->writeDefaultSolrTestSiteConfiguration();

Expand Down
15 changes: 3 additions & 12 deletions Tests/Integration/GarbageCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Scheduler\Scheduler;

Expand Down Expand Up @@ -93,6 +93,8 @@ protected function setUp(): void
$this->extensionConfiguration = GeneralUtility::makeInstance(ExtensionConfiguration::class);
$this->eventQueue = GeneralUtility::makeInstance(EventQueueItemRepository::class);
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['solr'] = [];
$GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)
->create('default');
}

protected function tearDown(): void
Expand Down Expand Up @@ -872,7 +874,6 @@ protected function prepareCanTriggerHookAfterRecordDeletion(): void
);

$this->cleanUpSolrServerAndAssertEmpty();
$this->fakeLanguageService();

// we hide the seconde page
$beUser = $this->fakeBEUser(1, 0);
Expand Down Expand Up @@ -913,16 +914,6 @@ protected function addToQueueAndIndexRecord($table, $uid): bool
return $result;
}

/**
* Prepares a LanguageService object
*/
protected function fakeLanguageService(): void
{
/** @var $languageService \TYPO3\CMS\Core\Localization\LanguageService */
$languageService = GeneralUtility::makeInstance(LanguageService::class);
$GLOBALS['LANG'] = $languageService;
}

/**
* Triggers event queue processing
*/
Expand Down
Loading

0 comments on commit eadcb96

Please sign in to comment.