Commit 06a66464 authored by R3 H6's avatar R3 H6 Committed by Oliver Bartsch
Browse files

[BUGFIX] Type check extbase parameter for array

If an argument on a plugin namespace is not an array,
Extbase failed hard with an type error exception.

Resolves: #91040
Releases: master, 10.4, 9.5
Change-Id: Ib613081aeb99232f1254a431fec57f15bb88b1c0
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68988

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent 7c43c5a1
......@@ -168,7 +168,8 @@ class RequestBuilder implements \TYPO3\CMS\Core\SingletonInterface
$getParameters = $typo3Request->getQueryParams()[$pluginNamespace] ?? [];
}
$bodyParameters = $typo3Request->getParsedBody()[$pluginNamespace] ?? [];
$parameters = $getParameters;
$bodyParameters = is_array($bodyParameters) ? $bodyParameters : [];
$parameters = is_array($getParameters) ? $getParameters : [];
ArrayUtility::mergeRecursiveWithOverrule($parameters, $bodyParameters);
} else {
$parameters = \TYPO3\CMS\Core\Utility\GeneralUtility::_GPmerged($pluginNamespace);
......
<?php
declare(strict_types = 1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
class RequestBuilderTest extends FunctionalTestCase
{
/**
* @test
*/
public function silentlyIgnoreInvalidParameterAndUseDefaultAction(): void
{
$pageArguments = new PageArguments(1, '0', ['tx_blog_example_blog' => 'not_an_array']);
$serverRequest = new ServerRequest(new Uri(''));
$serverRequest = $serverRequest->withAttribute('routing', $pageArguments);
$GLOBALS['TYPO3_REQUEST'] = $serverRequest;
$extensionName = 'blog_example';
$pluginName = 'blog';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
'ExtbaseTeam\BlogExample\Controller\BlogController' => [
'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
'alias' => 'BlogController',
'actions' => [
'list', 'show'
]
]
];
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration([
'extensionName' => $extensionName,
'pluginName' => $pluginName
]);
$requestBuilder = $objectManager->get(RequestBuilder::class);
$request = $requestBuilder->build();
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('list', $request->getControllerActionName());
}
}
Markdown is supported
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