[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
Tue Jan 7 17:28:49 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:  6.7.1
 Severity:  normal             |   Keywords:
  Focuses:  php-compatibility  |
-------------------------------+-----------------------------
 I've recently added some uses of the `wp_kses_post()` function to my
 plugin to pass [Plugin Check](https://wordpress.org/plugins/plugin-check/)
 tests, and found that there are a few cases where the variables I'm
 passing into that function may be null. When that's the case, I'm getting
 the following PHP error:

 `Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of
 type array|string is deprecated in wp-includes/kses.php on line 1805`

 I've traced this back to 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()`.

 I worked around the issue by adding `?: ''` into each instance of my use
 of `wp_kses_post()` but it seems to me that the `wp_kses_no_null()`
 function itself should be updated to handle the possibility that the
 `$content` input variable is null.

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


More information about the wp-trac mailing list