[wp-trac] [WordPress Trac] #62785: wp_kses_no_null() should be modified to handle $content having a null value

WordPress Trac noreply at wordpress.org
Wed Jan 8 19:40:08 UTC 2025


#62785: wp_kses_no_null() should be modified to handle $content having a null value
-------------------------------------------------+-------------------------
 Reporter:  room34                               |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  Formatting                           |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests php81       |     Focuses:  php-
  needs-testing                                  |  compatibility
-------------------------------------------------+-------------------------
Changes (by sabernhardt):

 * version:  6.7.1 =>


Comment:

 > the `wp_kses_no_null()` function, which is not designed to handle the
 PHP 8.x requirement that you can't pass null values into `preg_replace()`.

 The deprecation notice started with one of the PHP 8.x versions, but these
 KSES functions have explicitly required a string as the first parameter
 for more than 15 years. [6630] specified the type in documentation for
 `wp_kses_no_null()` and `wp_kses()`; [12125] documented the type when it
 introduced `wp_kses_post()`.

 A non-string value for that parameter could be a symptom of a bigger
 problem, and then silencing the deprecation notice with an empty string
 could hinder developers from discovering the error.

 Please investigate [https://plugins.trac.wordpress.org/changeset/3218521
 your plugin's code] (without the workarounds) to find where you might
 still have a `null` value in `wp_kses_post()`. For example, if either
 `$event['label']` or `$event['sublabel']` is somehow not a string, I think
 you would still have a problem with `str_replace()` in version 11.5.1.1.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62785#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list