Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update modifier.truncate.php #716

Closed
wants to merge 1 commit into from
Closed

Conversation

avatec
Copy link

@avatec avatec commented Jan 20, 2022

For PHP 8.1 if string is empty. Repairs Deprecated: mb_strlen(): Passing null to parameter #1 ($string) of type string is deprecated in vendor/smarty/smarty/libs/plugins/modifier.truncate.php on line 33

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
@Visualq
Copy link
Contributor

Visualq commented Jan 20, 2022

This is BC breaking, considering empty() returns true on "0","false", "", [] and null and your return type is "null" hence the return;

It would be better to:

if ($string === null) { return ''; }

However, the null problem might require a more general fix.

@avatec
Copy link
Author

avatec commented Jan 20, 2022

Yes, but i think no one should truncate 0, false or empty array. It should be checked before. We can also use !isset instead of empty.

@wisskid
Copy link
Contributor

wisskid commented Apr 26, 2022

Agree with @Visualq here. Also, we're going to needs tons of (string) casts or null checks to weed out every deprecation warning, I guess.

@wisskid wisskid closed this Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants