Skip to content

Commit

Permalink
[BUGFIX] Avoid undefined array keys error using stdWrap_bytes
Browse files Browse the repository at this point in the history
If either labels or base are not given, the default values
kick in: labels = iec and base = 1024

With the new fallback values in place test ContentObjectRendererTest
notAllStdWrapProcessorsAreCallableWithEmptyConfiguration()
needs a minor adaption.

Resolves: #98154
Releases: main, 11.5
Change-Id: Ib2a242454197be94a75fb3d5bffbb8d0be8a1523
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75519
Tested-by: core-ci <typo3@b13.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
brotkrueml authored and lolli42 committed Aug 19, 2022
1 parent f613738 commit 19633a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Expand Up @@ -2082,7 +2082,7 @@ public function stdWrap_case($content = '', $conf = [])
*/
public function stdWrap_bytes($content = '', $conf = [])
{
return GeneralUtility::formatSize((int)$content, $conf['bytes.']['labels'], $conf['bytes.']['base']);
return GeneralUtility::formatSize((int)$content, $conf['bytes.']['labels'] ?? '', $conf['bytes.']['base'] ?? 0);
}

/**
Expand Down
Expand Up @@ -3546,12 +3546,12 @@ public function allStdWrapProcessorsAreCallable(): void
* - Almost all stdWrap_[type] are callable if called with 2 parameters:
* - string $content Empty string.
* - array $conf ['type' => '', 'type.' => []].
* - Exceptions: stdWrap_numRows, stdWrap_split
* - Exceptions: stdWrap_numRows
* - The overall count is 91.
*
* Note:
*
* The two exceptions break, if the configuration is empty. This test just
* The exceptions break, if the configuration is empty. This test just
* tracks the different behaviour to gain information. It doesn't mean
* that it is an issue.
*
Expand All @@ -3563,7 +3563,7 @@ public function notAllStdWrapProcessorsAreCallableWithEmptyConfiguration(): void
GeneralUtility::setSingletonInstance(TimeTracker::class, $timeTrackerProphecy->reveal());

// `parseFunc` issues deprecation in case `htmlSanitize` is not given
$expectExceptions = ['numRows', 'parseFunc', 'bytes'];
$expectExceptions = ['numRows', 'parseFunc'];
$count = 0;
$processors = [];
$exceptions = [];
Expand Down Expand Up @@ -3982,6 +3982,16 @@ public function stdWrap_bytesDataProvider(): array
'1234567890',
['labels' => '', 'base' => 0],
],
'value 1234 iec no base' => [
'1.21 Ki',
'1234',
['labels' => 'iec'],
],
'value 1234 no labels base set' => [
'1.21 Ki',
'1234',
['base' => 0],
],
];
}

Expand Down

0 comments on commit 19633a3

Please sign in to comment.