Fluid icon indicating copy to clipboard operation
Fluid copied to clipboard

StandardVariableProvider type issue

Open ohader opened this issue 3 years ago • 3 comments

https://github.com/TYPO3/Fluid/blob/ae2d3d7ac201046275418c876fb82b63759678b1/src/Core/Variables/StandardVariableProvider.php#L261

$this->getByPath can be null leading to the following exception in TYPO3 v12 using PHP 8.1

#1476107295 TYPO3\CMS\Core\Error\Exception PHP Runtime Deprecation Notice: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in vendor/typo3fluid/fluid/src/Core/Variables/StandardVariableProvider.php line 261

ohader avatar Jan 24 '22 16:01 ohader

Can be reproduced by using a sub-reference to a variable that is not defined in a Fluid template, e.g. {{someUndefinedVariable}}

ohader avatar Jan 24 '22 17:01 ohader

While at it, the following should be fixed as well:

https://github.com/TYPO3/Fluid/blob/ae2d3d7ac201046275418c876fb82b63759678b1/src/Core/Variables/StandardVariableProvider.php#L258

- preg_match_all('/(\{.*\})/', $propertyPath, $matches);
+ preg_match_all('/(\{[^}]*\})/', $propertyPath, $matches);

which fixes {foo.{bar}.{baz}}

helhum avatar May 12 '22 11:05 helhum

@helhum Can you create a separate ticket for this? Thanks.

mbrodala avatar May 12 '22 12:05 mbrodala

Can be reproduced by using a sub-reference to a variable that is not defined in a Fluid template, e.g. {{someUndefinedVariable}}

Any workarounds? I have this: {settings.maxImageWidth.colPos.{colPos}.full}

stigfaerch avatar Jan 30 '23 09:01 stigfaerch

Btw - this is also the case for TYPO3 v11 and PHP 8.1

stigfaerch avatar Jan 30 '23 09:01 stigfaerch

Fixed the deprecation warning now. For the multi-sub-reference isssue Helmut mentioned: This is covered by #353 already, and we have https://github.com/TYPO3/Fluid/pull/663 and https://github.com/smoebody/Fluid/commit/51b0a926a7991c0353f3fc80df054bde10881c44 which both try to fix this. Let's continue with #353 for this.

lolli42 avatar May 04 '23 14:05 lolli42