Make WordPress Core

Opened 8 months ago

Closed 6 months ago

#63221 closed defect (bug) (invalid)

Deprecated Warning in wp_parse_list() When Passing Null Value

Reported by: dilipbheda's profile dilipbheda Owned by:
Milestone: 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 (3)

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


8 months ago
#1

#2 @swissspidy
8 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
6 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

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.