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

htmlspecialchars() - Deprecation warning in php 8.1 #748

Closed
MaximilianKresse opened this issue Mar 24, 2022 · 1 comment
Closed

htmlspecialchars() - Deprecation warning in php 8.1 #748

MaximilianKresse opened this issue Mar 24, 2022 · 1 comment

Comments

@MaximilianKresse
Copy link

Code:

$smarty = new \Smarty();
$smarty->setEscapeHtml(true);

$smarty->assign('value', null);

var_dump($smarty->fetch('string:{$value}'));

Expected output:

string(0) ""

Output in php >= 8.1:

string(215) "
Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in ...\7f3eb64ac896f10d0f0414cf415a097993be285b_2.string.php on line 18
"

I could fix this problem with a "default"-modifier but I think smarty should be robust enough to prevent this kind of errors. I see the problem in this line here.
The {$output} should be casted to string to prevent this error.

@wisskid
Copy link
Member

wisskid commented Apr 26, 2022

Thanks @MaximilianKresse. Closing this in favor of #750

@wisskid wisskid closed this as completed 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

No branches or pull requests

2 participants