Skip to content

Commit

Permalink
[BUGFIX] Make sure the baseVariants are respected
Browse files Browse the repository at this point in the history
In the ContentObjectRenderer there is the possibility to get
the Site Configuration. Here a simple array which is read out.

In the case of baseUrl, the baseVariants are now considered
with the possible conditions.

Resolves: #88847
Releases: master, 9.5
Change-Id: I8db7e9264e82d4021ea8fe63b690eb2ec09288e4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61375
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Daniel Maier <dani-maier@gmx.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
brandung-gs authored and andreaskienast committed Aug 8, 2019
1 parent 524b670 commit dbd8943
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4711,6 +4711,8 @@ public function getData($string, $fieldArray = null)
if ($site instanceof Site) {
if ($key === 'identifier') {
$retVal = $site->getIdentifier();
} elseif ($key === 'base') {
$retVal = $site->getBase();
} else {
try {
$retVal = ArrayUtility::getValueByPath($site->getConfiguration(), $key, '.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,38 @@ public function getDataWithTypeSite(): void
$this->assertEquals('yeah', $this->subject->getData('site:custom.config.nested'));
}

/**
* Checks if getData() works with type "site" and base variants
*
* @test
*/
public function getDataWithTypeSiteWithBaseVariants(): void
{
$cacheManagerProphecy = $this->prophesize(CacheManager::class);
$cacheManagerProphecy->getCache('core')->willReturn(new NullFrontend('core'));
GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
putenv('LOCAL_DEVELOPMENT=1');

$site = new Site('my-site', 123, [
'base' => 'http://prod.com',
'baseVariants' => [
[
'base' => 'http://staging.com',
'condition' => 'applicationContext == "Production/Staging"'
],
[
'base' => 'http://dev.com',
'condition' => 'getenv("LOCAL_DEVELOPMENT") == 1'
],
]
]);

$serverRequest = $this->prophesize(ServerRequestInterface::class);
$serverRequest->getAttribute('site')->willReturn($site);
$GLOBALS['TYPO3_REQUEST'] = $serverRequest->reveal();
$this->assertEquals('http://dev.com', $this->subject->getData('site:base'));
}

/**
* Checks if getData() works with type "siteLanguage"
*
Expand Down

0 comments on commit dbd8943

Please sign in to comment.