Bug #90786
closedNumberViewHelper: Avoid PHP Warning with (empty) string
100%
Description
From NumberViewHelper:
$stringToFormat = $renderChildrenClosure(); return number_format($stringToFormat, $decimals, $decimalSeparator, $thousandsSeparator);
If $stringToFormat is an empty string, number_format will produce a PHP Warning, as it expects the first parameter to be a float value (and not a string).
In my opinion the naming of the variable inside the number_format call is already misleading: $floatToFormat should make it clearer.
I don't know if it is intentional that an empty string or a string which is not a number produces a PHP Warning, to let the template developer ensure that there is a number.
If not, why not passing the number_format and gives back the unformatted string, e.g. in this - not tested - way:
$stringToFormat = (string)$renderChildrenClosure(); $floatToFormat = (float)$stringToFormat; if ($stringToFormat === '' || ($stringToFormat !== '0' && $floatToFormat === 0)) { return $stringToFormat; } return number_format($floatToFormat, $decimals, $decimalSeparator, $thousandsSeparator);
Updated by Gerrit Code Review over 4 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63798
Updated by Gerrit Code Review over 4 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63798
Updated by Gerrit Code Review over 4 years ago
Patch set 1 for branch 9.5 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/63776
Updated by Susanne Moog over 4 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 121e564c030e6f5af35bf72ecddd9d5f8edffc23.