Make WordPress Core

Opened 7 weeks ago

Last modified 7 weeks ago

#63221 new defect (bug)

Deprecated Warning in wp_parse_list() When Passing Null Value

Reported by: dilipbheda's profile dilipbheda Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch close
Focuses: php-compatibility Cc:

Description

When calling wp_parse_list( get_option( 'custom_theme_settings', null ) ), a deprecated warning appears in PHP 8.1+ due to passing null to preg_split().

Deprecated: preg_split(): Passing null to parameter #2 ($subject) of type string is deprecated 
in /var/www/html/codeinwp/wp-includes/functions.php on line 4967

Steps to Reproduce:

  1. Call get_option( 'custom_theme_settings', null ) where the option does not exist.
  2. Pass the result to wp_parse_list()
  3. Observe the deprecated warning in PHP 8.1+

Change History (2)

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


7 weeks ago
#1

#2 @swissspidy
7 weeks ago

  • Keywords close added

Our philosophy with this kind of issue has so far been that it should be fixed on the caller side. Instead of passing null to wp_parse_list() you should just pass a string.

So you should do wp_parse_list( get_option( 'custom_theme_settings', '' ) ) instead.

Note: See TracTickets for help on using tickets.