Skip to content

Commit

Permalink
[BUGFIX] Don't call mergeRecursiveWithOverrule with null argument
Browse files Browse the repository at this point in the history
During the removal of deprecated code in Extbase, a bug has been
introduced which is fixed with this patch.

Releases: master
Resolves: #87732
Relates: #87269
Change-Id: I5739acf64c65ad5eb79bcf16c6e7962366af59f6
Reviewed-on: https://review.typo3.org/c/59719
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
  • Loading branch information
alexanderschnitzler authored and maddy2101 committed Feb 23, 2019
1 parent 409a6e4 commit 5a470bc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
6 changes: 2 additions & 4 deletions typo3/sysext/extbase/Classes/Service/ExtensionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\FrontendRestrictionContainer;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;

Expand Down Expand Up @@ -246,9 +245,8 @@ public function getTargetPageTypeByFormat($extensionName, $format)
{
// Default behaviour
$settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName);
if (isset($settings['view']['formatToPageTypeMapping']) && is_array($settings['view']['formatToPageTypeMapping'])) {
ArrayUtility::mergeRecursiveWithOverrule($formatToPageTypeMapping, $settings['view']['formatToPageTypeMapping']);
}
$formatToPageTypeMapping = $settings['view']['formatToPageTypeMapping'] ?? [];
$formatToPageTypeMapping = is_array($formatToPageTypeMapping) ? $formatToPageTypeMapping : [];
return $formatToPageTypeMapping[$format] ?? 0;
}
}
42 changes: 42 additions & 0 deletions typo3/sysext/extbase/Tests/Unit/Service/ExtensionServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
use TYPO3\CMS\Core\Tests\Unit\Database\Mocks\MockPlatform;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManager;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Exception;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

Expand Down Expand Up @@ -402,4 +404,44 @@ public function getDefaultActionNameByPluginAndControllerReturnsFirstActionNameO
$actualResult = $this->extensionService->getDefaultActionNameByPluginAndController('SomeOtherExtensionName', 'SecondPlugin', 'SecondControllerName');
$this->assertEquals($expectedResult, $actualResult);
}

/**
* @test
*/
public function getTargetPageTypeByFormatReturnsZeroIfNoMappingIsSet(): void
{
$configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
$configurationManagerProphecy->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK,
'extension'
)->willReturn([]);
$this->extensionService->injectConfigurationManager($configurationManagerProphecy->reveal());

$result = $this->extensionService->getTargetPageTypeByFormat('extension', 'json');

$this->assertSame(0, $result);
}

/**
* @test
*/
public function getTargetPageTypeByFormatReturnsMappedPageTypeFromConfiguration(): void
{
$configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
$configurationManagerProphecy->getConfiguration(
ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK,
'extension'
)->willReturn([
'view' => [
'formatToPageTypeMapping' => [
'json' => 111
]
]
]);
$this->extensionService->injectConfigurationManager($configurationManagerProphecy->reveal());

$result = $this->extensionService->getTargetPageTypeByFormat('extension', 'json');

$this->assertSame(111, $result);
}
}

0 comments on commit 5a470bc

Please sign in to comment.