Deprecation error with php8.1 for Html::escape(NULL)

Created on 6 March 2022, almost 3 years ago
Updated 17 August 2023, over 1 year ago

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.

User interface changes

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Closed: duplicate

Version

9.4

Component
BaseΒ  β†’

Last updated about 2 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom rivimey

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024