From d14ac2669c6f0800e4e6e6ef5d5be7f8055c5207 Mon Sep 17 00:00:00 2001 From: Benni Mack <benni@typo3.org> Date: Tue, 28 Mar 2023 09:37:18 +0200 Subject: [PATCH] [BUGFIX] Fix PHP warning in FormFieldViewHelper When using a formField with a property name that only consists of a number (e.g. a UID), Fluid will now allow this. Resolves: #100281 Releases: main, 11.5 Change-Id: Ief95b87af1025f65ac0db1ed0c64b6fcf9c40bbe Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78573 Tested-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Oliver Bartsch <bo@cedev.de> Tested-by: core-ci <typo3@b13.com> --- .../ViewHelpers/Form/AbstractFormFieldViewHelper.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php index abc1b66eb731..314718e72499 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php @@ -118,7 +118,7 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper 'formObjectName' ); if (!empty($formObjectName)) { - $propertySegments = explode('.', $this->arguments['property'] ?? ''); + $propertySegments = explode('.', (string)($this->arguments['property'] ?? '')); $propertyPath = ''; foreach ($propertySegments as $segment) { $propertyPath .= '[' . $segment . ']'; @@ -136,7 +136,7 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper $name .= '[__identity]'; } } - return $name; + return (string)$name; } /** @@ -256,7 +256,7 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper ) { return; } - $propertySegments = explode('.', $this->arguments['property']); + $propertySegments = explode('.', (string)($this->arguments['property'] ?? '')); // hierarchical property. If there is no "." inside (thus $propertySegments == 1), we do not need to do anything if (count($propertySegments) < 2) { return; @@ -296,7 +296,7 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper */ protected function getPropertyValue() { - if ($this->arguments['property'] === null) { + if (!isset($this->arguments['property'])) { return null; } $viewHelperVariableContainer = $this->renderingContext->getViewHelperVariableContainer(); @@ -311,7 +311,7 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper FormViewHelper::class, 'formObject' ); - return ObjectAccess::getPropertyPath($formObject, $this->arguments['property']); + return ObjectAccess::getPropertyPath($formObject, (string)$this->arguments['property']); } /** @@ -364,7 +364,7 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper FormViewHelper::class, 'formObjectName' ); - return $originalRequestMappingResults->forProperty($formObjectName)->forProperty($this->arguments['property']); + return $originalRequestMappingResults->forProperty($formObjectName)->forProperty((string)$this->arguments['property']); } /** -- GitLab