Skip to content

Commit 9a80f69

Browse files
committed
- ensures the $settings_fields param on the "graphql_get_setting_section_field_value" filter is an array before passing it to the filter
1 parent b288907 commit 9a80f69

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

access-functions.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,21 +813,24 @@ static function ( \WPGraphQL\Admin\Settings\SettingsRegistry $registry ) use ( $
813813
* @since 0.13.0
814814
*/
815815
function get_graphql_setting( string $option_name, $default_value = '', $section_name = 'graphql_general_settings' ) {
816-
$section_fields = get_option( $section_name );
816+
$section_fields = get_option( $section_name, [] );
817817

818818
/**
819819
* Filter the section fields
820-
820+
*
821821
* @param array<string,mixed> $section_fields The values of the fields stored for the section
822822
* @param string $section_name The name of the section
823823
* @param mixed $default_value The default value for the option being retrieved
824824
*/
825825
$section_fields = apply_filters( 'graphql_get_setting_section_fields', $section_fields, $section_name, $default_value );
826826

827+
// ensure the filtered sections fields are an array before proceeding
828+
$section_fields = is_array( $section_fields ) ? $section_fields : [];
829+
827830
/**
828831
* Get the value from the stored data, or return the default
829832
*/
830-
$value = isset( $section_fields[ $option_name ] ) ? $section_fields[ $option_name ] : $default_value;
833+
$value = $section_fields[ $option_name ] ?? $default_value;
831834

832835
/**
833836
* Filter the value before returning it

0 commit comments

Comments
 (0)