Skip to content

Commit

Permalink
[BUGFIX] Fix PHP warnings for undefined array key
Browse files Browse the repository at this point in the history
  • Loading branch information
theLine committed Feb 23, 2023
1 parent 67d7756 commit 8a9a75c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 5 additions & 1 deletion Classes/Mvc/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ class RequestBuilder
*/
public function build($rawRequestArgument): Request
{
if (empty($rawRequestArgument['context']) || !is_string($rawRequestArgument['context'])) {
if (
! array_key_exists('context', $rawRequestArgument)
|| empty($rawRequestArgument['context'])
|| !is_string($rawRequestArgument['context'])
) {
throw new Exception('tx_typoscriptrendering|context must not be empty and must be of type string!', 1403793452);
}
$rawRequest = @json_decode($rawRequestArgument['context'], true);
Expand Down
16 changes: 10 additions & 6 deletions Classes/Uri/TyposcriptRenderingUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private function parseViewHelperContext(ViewHelperContext $viewHelperContext): v
$pluginName = $arguments['pluginName'] ?? null;
$extensionName = $arguments['extensionName'] ?? null;
$contextRecord = $arguments['contextRecord'];
$additionalParams = $arguments['additionalParams'];
$additionalParams = $arguments['additionalParams'] ?? [];
$renderingPath = $arguments['typoscriptObjectPath'] ?? null;

if ($pluginName === null) {
Expand Down Expand Up @@ -95,8 +95,10 @@ private function parseViewHelperContext(ViewHelperContext $viewHelperContext): v
->setAddQueryString($arguments['addQueryString'] ?? false)
->setAddQueryStringMethod('GET')
->setArgumentsToBeExcludedFromQueryString($arguments['argumentsToBeExcludedFromQueryString'] ?? []);
if (MathUtility::canBeInterpretedAsInteger($arguments['pageUid'])) {
$uriBuilder->setTargetPageUid((int)$arguments['pageUid']);

$targetPageUid = $arguments['pageUid'] ?? null;
if (MathUtility::canBeInterpretedAsInteger($targetPageUid)) {
$uriBuilder->setTargetPageUid((int)$targetPageUid);
}

$this->parseUri(
Expand Down Expand Up @@ -124,7 +126,7 @@ private function parseWidgetContext(ViewHelperContext $viewHelperContext): void
$pluginName = $arguments['pluginName'] ?? null;
$extensionName = $arguments['extensionName'] ?? null;
$contextRecord = $arguments['contextRecord'];
$additionalParams = $arguments['additionalParams'];
$additionalParams = $arguments['additionalParams'] ?? [];
$renderingPath = $arguments['typoscriptObjectPath'] ?? null;

if ($pluginName === null) {
Expand Down Expand Up @@ -167,8 +169,10 @@ private function parseWidgetContext(ViewHelperContext $viewHelperContext): void
->setAddQueryString(true)
->setAddQueryStringMethod('GET')
->setArgumentsToBeExcludedFromQueryString($arguments['argumentsToBeExcludedFromQueryString'] ?? []);
if (MathUtility::canBeInterpretedAsInteger($arguments['pageUid'])) {
$uriBuilder->setTargetPageUid((int)$arguments['pageUid']);

$targetPageUid = $arguments['pageUid'] ?? null;
if (MathUtility::canBeInterpretedAsInteger($targetPageUid)) {
$uriBuilder->setTargetPageUid((int)$targetPageUid);
}

$uri = $uriBuilder->build();
Expand Down

0 comments on commit 8a9a75c

Please sign in to comment.