Problem/Motivation
Something in my site ends up calling Html::escape(NULL), and because the test server is running php8.1 I get a deprecation error which causes general mayhem with the site. I cannot see why this NULL is passed in.
Steps to reproduce
Unknown.
Proposed resolution
Modify the function to be more forgiving of unexpected input:
public static function escape($text) {
if (empty($text)) return '';
return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
}
Remaining tasks
If this is a general problem, consider whether other calls (e.g. to entity decode) might also benefit.