Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Options, Meta APIs: Check setting group exists before search in unreg…
…ister_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. git-svn-id: https://develop.svn.wordpress.org/trunk@56817 602fd350-edb4-49c9-b593-d223f7449a82
- Loading branch information