Skip to content

Commit

Permalink
!!![CLEANUP] Remove obsolete TYPO3 registry usages
Browse files Browse the repository at this point in the history
TYPO3 registry was mainly used for connection storage, which is
obsolete since the introduction of the Site handling. Luke limit
read by the InfoModuleController was never set in the registry,
so for now the fallback value of 20000 is used.

This is a breaking change as the SiteRepository expected the
registry to be passed, which is no longer necessary.

Resolves: #3792
  • Loading branch information
dkd-friedrich committed Sep 27, 2023
1 parent f528685 commit 81b8f2b
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 22 deletions.
7 changes: 1 addition & 6 deletions Classes/Controller/Backend/Search/InfoModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use ApacheSolrForTypo3\Solr\System\Validator\Path;
use Doctrine\DBAL\Exception as DBALException;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Registry;
use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
Expand Down Expand Up @@ -207,13 +206,9 @@ protected function collectIndexFieldsInfo(): void
];
if ($coreAdmin->ping()) {
$lukeData = $coreAdmin->getLukeMetaData();

/** @var Registry $registry */
$registry = GeneralUtility::makeInstance(Registry::class);
$limit = $registry->get('tx_solr', 'luke.limit', 20000);
$limitNote = '';

if (isset($lukeData->index->numDocs) && $lukeData->index->numDocs > $limit) {
if (isset($lukeData->index->numDocs) && $lukeData->index->numDocs > 20000) {
$limitNote = '<em>Too many terms</em>';
} elseif (isset($lukeData->index->numDocs)) {
$limitNote = 'Nothing indexed';
Expand Down
5 changes: 0 additions & 5 deletions Classes/Domain/Site/SiteRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use Doctrine\DBAL\Exception as DBALException;
use Throwable;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Registry;
use TYPO3\CMS\Core\Site\Entity\Site as CoreSite;
use TYPO3\CMS\Core\Site\SiteFinder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -46,8 +45,6 @@ class SiteRepository

protected TwoLevelCache $runtimeCache;

protected Registry $registry;

protected SiteFinder $siteFinder;

protected ExtensionConfiguration $extensionConfiguration;
Expand All @@ -57,14 +54,12 @@ class SiteRepository
public function __construct(
RootPageResolver $rootPageResolver = null,
TwoLevelCache $twoLevelCache = null,
Registry $registry = null,
SiteFinder $siteFinder = null,
ExtensionConfiguration $extensionConfiguration = null,
FrontendEnvironment $frontendEnvironment = null
) {
$this->rootPageResolver = $rootPageResolver ?? GeneralUtility::makeInstance(RootPageResolver::class);
$this->runtimeCache = $twoLevelCache ?? GeneralUtility::makeInstance(TwoLevelCache::class, 'runtime');
$this->registry = $registry ?? GeneralUtility::makeInstance(Registry::class);
$this->siteFinder = $siteFinder ?? GeneralUtility::makeInstance(SiteFinder::class);
$this->extensionConfiguration = $extensionConfiguration ?? GeneralUtility::makeInstance(ExtensionConfiguration::class);
$this->frontendEnvironment = $frontendEnvironment ?? GeneralUtility::makeInstance(FrontendEnvironment::class);
Expand Down
5 changes: 1 addition & 4 deletions Tests/Unit/Domain/Site/SiteRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use ApacheSolrForTypo3\Solr\System\Cache\TwoLevelCache;
use ApacheSolrForTypo3\Solr\Tests\Unit\SetUpUnitTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\CMS\Core\Registry;
use TYPO3\CMS\Core\Site\Entity\Site as CoreSite;
use TYPO3\CMS\Core\Site\Entity\SiteLanguage;
use TYPO3\CMS\Core\Site\SiteFinder;
Expand All @@ -38,7 +37,6 @@ class SiteRepositoryTest extends SetUpUnitTestCase
{
protected TwoLevelCache|MockObject $cacheMock;
protected RootPageResolver|MockObject $rootPageResolverMock;
protected Registry|MockObject $registryMock;
protected SiteRepository|MockObject $siteRepository;
protected SiteFinder|MockObject $siteFinderMock;

Expand All @@ -47,12 +45,11 @@ protected function setUp(): void
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['solr'] = [];
$this->cacheMock = $this->createMock(TwoLevelCache::class);
$this->rootPageResolverMock = $this->createMock(RootPageResolver::class);
$this->registryMock = $this->createMock(Registry::class);
$this->siteFinderMock = $this->createMock(SiteFinder::class);

// we mock buildSite to avoid the creation of real Site objects and pass all dependencies as mock
$this->siteRepository = $this->getMockBuilder(SiteRepository::class)
->setConstructorArgs([$this->rootPageResolverMock, $this->cacheMock, $this->registryMock, $this->siteFinderMock])
->setConstructorArgs([$this->rootPageResolverMock, $this->cacheMock, $this->siteFinderMock])
->onlyMethods(['buildSite'])
->getMock();
parent::setUp();
Expand Down
7 changes: 0 additions & 7 deletions ext_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@ CREATE TABLE tx_solr_eventqueue_item (
KEY error (error),
) ENGINE=InnoDB;

#
# Update size of entry_value for table 'sys_registry'
#
CREATE TABLE sys_registry (
entry_value longblob
) ENGINE=InnoDB;

#
# Extending 'pages' table with extra keys
#
Expand Down

0 comments on commit 81b8f2b

Please sign in to comment.