Make WordPress Core

Opened 6 weeks ago

Closed 5 weeks ago

#63108 closed defect (bug) (duplicate)

deprecated warning in /wp-includes/kses.php

Reported by: rpayne7264's profile rpayne7264 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Formatting Keywords: has-patch
Focuses: Cc:

Description

one deprecated warning in /wp-includes/kses.php:

Backtrace from warning 'preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated' at /wp-includes/kses.php 1805:

This is the line of code causing the error: $content = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $content );

This is the adjusted code to fix the issue: $content = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $content ?? '');

Change History (2)

This ticket was mentioned in PR #8512 on WordPress/wordpress-develop by @rpayne7264.


6 weeks ago
#1

  • Keywords has-patch added

Update /wp-includes/kses.php to fix deprecated warnings:

-- Backtrace from warning 'preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated' at /wp-includes/kses.php 1805:

This was the line of code causing the error:
$content = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', , $content );

around line 1805, updated code to: $content = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $content ?? '');
The ?? operator ensures that if $content is null, it is replaced with an empty string () before being processed by preg_replace().

Trac ticket: https://core.trac.wordpress.org/ticket/63108

#2 @sabernhardt
5 weeks ago

  • Component changed from Security to Formatting
  • Keywords changes-requested removed
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 6.7.2 deleted

#62785 already proposed silencing the deprecation notice in wp_kses_no_null().

Note: See TracTickets for help on using tickets.