Skip to content
Snippets Groups Projects
Commit c2f7e056 authored by Christian Kuhn's avatar Christian Kuhn Committed by Anja Leichsenring
Browse files

[BUGFIX] Avoid implicit conversion to int in StringUtility

StringUtility::multibyteStringPad() does a happy division
feeding str_repeat() to evenly pad on left and right side.

The division result can be a float. With PHP 8.1,
str_repeat($string, float) emits E_DEPRECATED
"Implicit conversion from float looses precision.".

Avoid this with an explicit cast.

Resolves: #95772
Releases: master
Change-Id: I8b918f6a4a304a059729e573a45626d1d5d27d10
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71970


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarJochen <rothjochen@gmail.com>
Tested-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: default avatarJochen <rothjochen@gmail.com>
Reviewed-by: default avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent cbc0b420
Branches
Tags
No related merge requests found
......@@ -203,7 +203,7 @@ class StringUtility
$padded = ((int)($leftPadCount / $pad_string_len)) * $pad_string_len;
$leftPad = str_repeat($pad_string, (int)($leftPadCount / $pad_string_len));
$leftPad .= mb_substr($pad_string, 0, $leftPadCount - $padded);
$string = $leftPad . $string . str_repeat($pad_string, ($length - $len)/$pad_string_len);
$string = $leftPad . $string . str_repeat($pad_string, (int)(($length - $len)/$pad_string_len));
$string .= mb_substr($pad_string, 0, ($length - $len) % $pad_string_len);
return $string;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment