mzur/kirby-uniform

PHP Deprecated htmlspecialchars(): Passing null to paramete

Closed this issue · 4 comments

Ran into this error after updating my PHP version to 8.1:
htmlspecialchars_decode(): Passing null to parameter #1 ($string) of type string is deprecated

Whoops\Exception\ErrorException …/site/plugins/kirby-uniform-master/vendor/mzur/kirby-form/src/Form.php332

protected function decodeField($data) { return is_array($data) ? array_map([$this, 'decodeField'], $data) : htmlspecialchars_decode($data); }

Updated with a conditional and seems to have fixed the error.

protected function decodeField($data) { return is_array($data) ? array_map([$this, 'decodeField'], $data) : htmlspecialchars_decode($data ?: ''); }

mzur commented

Which version of Uniform do you use? This was fixed in kirby-form v3.0.1 which is included in Uniform v5.0.2.

@mzur possibly v4, as the readme contains this composer install command: composer require mzur/kirby-uniform:^4

(I also blindly assumed that's thee latest version 😳)

I'll try to finally get the #214 done and then I can PR the readme update

mzur commented

@adamkiss Well-spotted, thanks! I've removed the version constraint so people get the latest version. However, I think the HTML encoding was only introduced in v5.

mzur commented

Please reopen if there is anything else to discuss.