Options, Meta APIs: Check setting group exists before search in unregister_setting().
Checks if the given `$option_group` exists before searching for the `$option_name`. Sets the `$pos` to `false`, as `array_search()` returns `false` if the option name (needle) does not exist. This changeset fixes 2 different PHP Warning|Notice scenarios: 1. When the global `$new_allowed_options` is `null`, fixes raising `Trying to access array offset on value of type null` PHP Notice (PHP 7.4) | Warning (on PHP 8). 2. When the global `$new_allowed_options` is an `array` and the setting group key does not exist, fixes raising "Undefined index: unknown_setting_group" PHP Notice (PHP 7) | Warning (on PHP 8). For both scenarios, the `array_search()` is skipped and the `$pos` is set to a default of `false`, i.e. which is the value returned when `array_search()` is unsuccessful. Props xknown, hellofromTonya, nicolefurlan, oglekler, SergeyBiryukov, shailu25. Fixes #57674. Built from https://develop.svn.wordpress.org/trunk@56817 git-svn-id: http://core.svn.wordpress.org/trunk@56329 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6468f40e61
commit
eb9aaa5f9e
|
@ -2903,7 +2903,10 @@ function unregister_setting( $option_group, $option_name, $deprecated = '' ) {
|
|||
$option_group = 'reading';
|
||||
}
|
||||
|
||||
$pos = false;
|
||||
if ( isset( $new_allowed_options[ $option_group ] ) ) {
|
||||
$pos = array_search( $option_name, (array) $new_allowed_options[ $option_group ], true );
|
||||
}
|
||||
|
||||
if ( false !== $pos ) {
|
||||
unset( $new_allowed_options[ $option_group ][ $pos ] );
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.4-beta2-56816';
|
||||
$wp_version = '6.4-beta2-56817';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue