Make WordPress Core

Opened 8 months ago

Last modified 5 weeks ago

#57674 new defect (bug)

unregister_setting() raises a PHP warning on unknown settings

Reported by: xknown's profile xknown Owned by:
Milestone: 6.4 Priority: normal
Severity: normal Version:
Component: Options, Meta APIs Keywords: php81 has-patch has-unit-tests needs-testing
Focuses: php-compatibility Cc:

Description

Starting from PHP 8.x, attempting to unregister an undefined setting results in PHP warnings: Warning: Trying to access array offset on value of type null.

unregister_setting( 'somethingrandom', 'somethingrandom' );

Change History (4)

This ticket was mentioned in PR #4035 on WordPress/wordpress-develop by xknown.


8 months ago
#1

  • Keywords has-patch has-unit-tests added

#2 @hellofromTonya
8 weeks ago

  • Focuses php-compatibility added

I'll mark this ticket as a php-compatibility focus to include it in the PHP 8.1 compat exclusion list.

#3 @SergeyBiryukov
8 weeks ago

  • Milestone changed from Awaiting Review to 6.4

Good catch, we already check if $wp_registered_settings[ $option_name ] is set there, so I think it makes sense to do the same for $new_allowed_options[ $option_group ].

#4 @oglekler
5 weeks ago

  • Keywords needs-testing added
Note: See TracTickets for help on using tickets.