Skip to content

Commit

Permalink
Update modifier.truncate.php
Browse files Browse the repository at this point in the history
For PHP 8.1 if string is empty. Repairs Deprecated: mb_strlen(): Passing null to parameter smarty-php#1 ($string) of type string is deprecated in vendor/smarty/smarty/libs/plugins/modifier.truncate.php on line 33
  • Loading branch information
avatec authored Jan 20, 2022
1 parent cdf0f2b commit 72085ec
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libs/plugins/modifier.truncate.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
if ($length === 0) {
return '';
}
if(empty( $string )) {
return;
}
if (Smarty::$_MBSTRING) {
if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
$length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
Expand Down

0 comments on commit 72085ec

Please sign in to comment.