Make WordPress Core

#63221 closed defect (bug) (invalid)

Deprecated Warning in wp_parse_list() When Passing Null Value

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

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 (3)

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


17 months ago
#1

#2 @swissspidy
17 months 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.

#3 @karmatosed
15 months ago

  • Milestone Awaiting Review
  • Resolutioninvalid
  • Status newclosed

Thank you for reporting. However, for now I think moving this on with a close is the better approach as has been recommended. Let's do just that and we can always review should further information come up. Thank you.

Note: See TracTickets for help on using tickets.