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

Fix PHP8.1 deprecation warnings on null string in modifiers #834

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

AdrienPoupa
Copy link
Contributor

I noticed that if one is calling |truncate on null, it triggers E_DEPRECATED: mb_strlen(): Passing null to parameter #1 ($string) of type string is deprecated on PHP 8.1.

This is expected, but given the modifier accepts null we may as well return an empty string before calling the function.

@rudiedirkx
Copy link

Didn't we do this recently in a huge PR? Or did that not include modifiers & functions? It seems inefficient to do every modifier/function separately like this and d304d34 and more. On the other hand, I don't even run 8.1 yet, so I'm not going to fix all of them =) so you can safely ignore me.

@AdrienPoupa
Copy link
Contributor Author

I didn't see it on master but if it's in a different branch, then for sure this can be closed.

@AdrienPoupa
Copy link
Contributor Author

AdrienPoupa commented Dec 19, 2022

I added some more casts to modifiers that were probably left out previously, it should all be good now :)

@AdrienPoupa AdrienPoupa changed the title Fix PHP8.1 deprecation error on null string Fix PHP8.1 deprecation errors on null string Dec 19, 2022
Prevents E_DEPRECATED: mb_strlen(): Passing null to parameter smarty-php#1 ($string) of type string is deprecated
@AdrienPoupa AdrienPoupa changed the title Fix PHP8.1 deprecation errors on null string Fix PHP8.1 deprecation warnings on null string Dec 19, 2022
@AdrienPoupa AdrienPoupa changed the title Fix PHP8.1 deprecation warnings on null string Fix PHP8.1 deprecation warnings on null string in modifiers Dec 19, 2022
@AdrienPoupa
Copy link
Contributor Author

AdrienPoupa commented Jan 16, 2023

We've been using this in production for some time now, it works fine. We would love to see it merged and released so we can drop our internal fork :)

@wisskid wisskid merged commit 5988116 into smarty-php:master Jan 16, 2023
@wisskid
Copy link
Contributor

wisskid commented Jan 16, 2023

No problem! Thank you for your contribution.

@AdrienPoupa
Copy link
Contributor Author

Thanks for the merge!

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