From f7daebe481fdeee14dc78f3ca2a5b884f91a1059 Mon Sep 17 00:00:00 2001 From: Austin Burdine Date: Wed, 2 Sep 2020 00:52:48 -0400 Subject: [PATCH 1/5] Fix memory leak issue with empty flex content layouts --- src/class-config.php | 7 ++++--- tests/wpunit/PostObjectFieldsTest.php | 9 +++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/class-config.php b/src/class-config.php index f675fc0..ed13ec8 100644 --- a/src/class-config.php +++ b/src/class-config.php @@ -1020,7 +1020,7 @@ protected function register_graphql_field( $type_name, $field_name, $config ) { $layout['parent'] = $acf_field; $layout['show_in_graphql'] = isset( $acf_field['show_in_graphql'] ) ? (bool) $acf_field['show_in_graphql'] : true; - $this->add_field_group_fields( $layout, $flex_field_layout_name ); + $this->add_field_group_fields( $layout, $flex_field_layout_name, true ); } } @@ -1058,8 +1058,9 @@ protected function register_graphql_field( $type_name, $field_name, $config ) { * * @param array $field_group The group to add to the Schema. * @param string $type_name The Type name in the GraphQL Schema to add fields to. + * @param bool $layout Whether or not these fields are part of a Flex Content layout. */ - protected function add_field_group_fields( $field_group, $type_name ) { + protected function add_field_group_fields( $field_group, $type_name, $layout = false ) { /** * If the field group has the show_in_graphql setting configured, respect it's setting @@ -1078,7 +1079,7 @@ protected function add_field_group_fields( $field_group, $type_name ) { /** * Get the fields in the group. */ - $acf_fields = ! empty( $field_group['sub_fields'] ) ? $field_group['sub_fields'] : acf_get_fields( $field_group ); + $acf_fields = ! empty( $field_group['sub_fields'] ) || $layout ? $field_group['sub_fields'] : acf_get_fields( $field_group ); /** * If there are no fields, bail diff --git a/tests/wpunit/PostObjectFieldsTest.php b/tests/wpunit/PostObjectFieldsTest.php index 1acfe39..388cb9c 100644 --- a/tests/wpunit/PostObjectFieldsTest.php +++ b/tests/wpunit/PostObjectFieldsTest.php @@ -2269,6 +2269,15 @@ protected function register_fields() { 'min' => '', 'max' => '', ), + 'layout_5d74257693147' => array( + 'key' => 'layout_5d74257693147', + 'name' => 'group_3', + 'label' => 'Group Three', + 'display' => 'block', + 'sub_fields' => array(), + 'min' => '', + 'max' => '', + ), ), 'button_label' => 'Add Row', 'min' => '', From 01c8b473f5edbdfaf527e1dc5e086b580a7fe57e Mon Sep 17 00:00:00 2001 From: Bronson Quick Date: Mon, 21 Sep 2020 16:25:42 +1000 Subject: [PATCH 2/5] Allow decimals in Range fields --- src/class-config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class-config.php b/src/class-config.php index f675fc0..588d49c 100644 --- a/src/class-config.php +++ b/src/class-config.php @@ -446,7 +446,7 @@ protected function register_graphql_field( $type_name, $field_name, $config ) { $field_config['type'] = 'String'; break; case 'range': - $field_config['type'] = 'Integer'; + $field_config['type'] = 'String'; break; case 'number': $field_config['type'] = 'Float'; From e9ffdf573ffbbf161eea5e8418305c7c4e08be4c Mon Sep 17 00:00:00 2001 From: Bronson Quick Date: Fri, 25 Sep 2020 17:05:37 +1000 Subject: [PATCH 3/5] Change to Float --- src/class-config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class-config.php b/src/class-config.php index 588d49c..d16eca7 100644 --- a/src/class-config.php +++ b/src/class-config.php @@ -446,7 +446,7 @@ protected function register_graphql_field( $type_name, $field_name, $config ) { $field_config['type'] = 'String'; break; case 'range': - $field_config['type'] = 'String'; + $field_config['type'] = 'Float'; break; case 'number': $field_config['type'] = 'Float'; From 2ffafbf737047718efd146a5f602aa5db6744cc6 Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Thu, 22 Oct 2020 08:43:16 -0600 Subject: [PATCH 4/5] - Update version for Release --- wp-graphql-acf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-graphql-acf.php b/wp-graphql-acf.php index 2f07b8c..8234666 100644 --- a/wp-graphql-acf.php +++ b/wp-graphql-acf.php @@ -7,7 +7,7 @@ * Author URI: https://www.wpgraphql.com * Text Domain: wp-graphql-acf * Domain Path: /languages - * Version: 0.3.5 + * Version: 0.3.6 * Requires PHP: 7.0 * GitHub Plugin URI: https://github.com/afragen/github-updater * From 6b2b0fb6d6bd7ed3bb334c996277956dc2e57d97 Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Thu, 22 Oct 2020 08:45:59 -0600 Subject: [PATCH 5/5] - update version for release --- wp-graphql-acf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wp-graphql-acf.php b/wp-graphql-acf.php index 8234666..810f4d9 100644 --- a/wp-graphql-acf.php +++ b/wp-graphql-acf.php @@ -7,7 +7,7 @@ * Author URI: https://www.wpgraphql.com * Text Domain: wp-graphql-acf * Domain Path: /languages - * Version: 0.3.6 + * Version: 0.4.0 * Requires PHP: 7.0 * GitHub Plugin URI: https://github.com/afragen/github-updater *