Skip to content
Snippets Groups Projects
Commit 504c9f9b authored by Stefan Bürk's avatar Stefan Bürk
Browse files

[TASK] Use `SiteConfiguration` from DI in `SiteBasedTestTrait`

`SiteBasedTestTrait` created a instance of the `SiteConfiguration`
using the PHP `new` keyword for writing functional test instance
site configurations.

It is possible, that the `SiteConfiguration` is retrieved from
the `Dependency Injection container` by code executed before
the test releated site configuration is written, which does not
reset the instance based `SiteConfiguration->$firstLevelCache`
property and later retrieving site configurations using the
`SiteFinder`, for example in rootline and other operations,
cannot find the test instance configurations.

This change now uses the `SiteConfiguration` from the test
instance `Dependency Injection container` which ensures that
the internal first level cache is properly reset on `write()`
actions.

Resolves: #103470
Releases: main, 12.4
Change-Id: I70368e56abd10e55f06d3813371c4538ad704136
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83572


Reviewed-by: default avatarBenjamin Franzke <ben@bnf.dev>
Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: default avatarBenni Mack <benni@typo3.org>
Tested-by: default avatarBenjamin Franzke <ben@bnf.dev>
Reviewed-by: default avatarStefan Bürk <stefan@buerk.tech>
Tested-by: default avatarBenni Mack <benni@typo3.org>
parent 1350e2b8
Branches
Tags
No related merge requests found
...@@ -17,7 +17,6 @@ declare(strict_types=1); ...@@ -17,7 +17,6 @@ declare(strict_types=1);
namespace TYPO3\CMS\Core\Tests\Functional\SiteHandling; namespace TYPO3\CMS\Core\Tests\Functional\SiteHandling;
use Psr\EventDispatcher\EventDispatcherInterface;
use TYPO3\CMS\Core\Configuration\SiteConfiguration; use TYPO3\CMS\Core\Configuration\SiteConfiguration;
use TYPO3\CMS\Core\Tests\Functional\Fixtures\Frontend\PhpError; use TYPO3\CMS\Core\Tests\Functional\Fixtures\Frontend\PhpError;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
...@@ -60,12 +59,7 @@ trait SiteBasedTestTrait ...@@ -60,12 +59,7 @@ trait SiteBasedTestTrait
if (!empty($errorHandling)) { if (!empty($errorHandling)) {
$configuration['errorHandling'] = $errorHandling; $configuration['errorHandling'] = $errorHandling;
} }
$siteConfiguration = new SiteConfiguration( $siteConfiguration = $this->get(SiteConfiguration::class);
$this->instancePath . '/typo3conf/sites/',
$this->get(EventDispatcherInterface::class),
$this->get('cache.core')
);
try { try {
// ensure no previous site configuration influences the test // ensure no previous site configuration influences the test
GeneralUtility::rmdir($this->instancePath . '/typo3conf/sites/' . $identifier, true); GeneralUtility::rmdir($this->instancePath . '/typo3conf/sites/' . $identifier, true);
...@@ -79,11 +73,7 @@ trait SiteBasedTestTrait ...@@ -79,11 +73,7 @@ trait SiteBasedTestTrait
string $identifier, string $identifier,
array $overrides array $overrides
): void { ): void {
$siteConfiguration = new SiteConfiguration( $siteConfiguration = $this->get(SiteConfiguration::class);
$this->instancePath . '/typo3conf/sites/',
$this->get(EventDispatcherInterface::class),
$this->get('cache.core')
);
$configuration = $siteConfiguration->load($identifier); $configuration = $siteConfiguration->load($identifier);
$configuration = array_merge($configuration, $overrides); $configuration = array_merge($configuration, $overrides);
try { try {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment