From 65005242ae680bd32bd3b745d42d5ec9d7411a1d Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Wed, 24 Apr 2024 15:35:02 -0600 Subject: [PATCH 1/3] - update changelog, versions for release --- CHANGELOG.md | 14 ++++++++++++++ readme.txt | 10 ++++++++++ wpgraphql-acf.php | 4 ++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c686270..8f00443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 2.3.0 + +## Update Notice + +This release refactored some internals regarding how Clone fields and Group fields behave. There was no intentional breaking changes to the Schema, but if you are using Clone and Group fields there is a chance that if you were benefiting from a "bug as a feature" there might be some changes that could impact your Schema and/or resolvers, we recommend testing this update on a staging site to ensure things are still working for you as expected. Should you run into any problems, please [open a new issue](https://github.com/wp-graphql/wpgraphql-acf/issues/new/choose) and provide as much detail as possible to help us reproduce the scenario. Thanks! 🙏 + +## New Features + +- [#193](https://github.com/wp-graphql/wpgraphql-acf/pull/193): feat: improved handling of clone and group fields + +## Chores / Bugfixes + +- [#194](https://github.com/wp-graphql/wpgraphql-acf/pull/194): ci: test against WordPress 6.5 + ## 2.2.0 ## New Features diff --git a/readme.txt b/readme.txt index 0f24915..3e1f012 100644 --- a/readme.txt +++ b/readme.txt @@ -104,6 +104,10 @@ Learn more about how [Appsero collects and uses data](https://appsero.com/privac == Upgrade Notice == += 2.3.0 = + +This release refactored some internals regarding how Clone fields and Group fields behave. There was no intentional breaking changes to the Schema, but if you are using Clone and Group fields there is a chance that if you were benefiting from a "bug as a feature" there might be some changes that could impact your Schema and/or resolvers, we recommend testing this update on a staging site to ensure things are still working for you as expected. Should you run into any problems, please [open a new issue](https://github.com/wp-graphql/wpgraphql-acf/issues/new/choose) and provide as much detail as possible to help us reproduce the scenario. Thanks! 🙏 + = 2.1.0 = While fixing some [performance issues](https://github.com/wp-graphql/wpgraphql-acf/pull/152) we had to adjust the fallback logic for mapping ACF Field Groups to the Schema if they do not have "graphql_types" defined. @@ -116,6 +120,12 @@ This release is a complete re-architecture of WPGraphQL for ACF, introducing bre == Changelog == += 2.3.0 = + +**New Features** + +**Chores / Bugfixes** + = 2.2.0 = **New Features** diff --git a/wpgraphql-acf.php b/wpgraphql-acf.php index dadb73b..6613ada 100644 --- a/wpgraphql-acf.php +++ b/wpgraphql-acf.php @@ -4,7 +4,7 @@ * Description: WPGraphQL for ACF seamlessly integrates Advanced Custom Fields with WPGraphQL. * Author: WPGraphQL, Jason Bahl * Author URI: https://www.wpgraphql.com - * Version: 2.2.0 + * Version: 2.3.0 * Text Domain: wpgraphql-acf * Requires PHP: 7.3 * Requires at least: 5.9 @@ -31,7 +31,7 @@ } if ( ! defined( 'WPGRAPHQL_FOR_ACF_VERSION' ) ) { - define( 'WPGRAPHQL_FOR_ACF_VERSION', '2.2.0' ); + define( 'WPGRAPHQL_FOR_ACF_VERSION', '2.3.0' ); } if ( ! defined( 'WPGRAPHQL_FOR_ACF_VERSION_WPGRAPHQL_REQUIRED_MIN_VERSION' ) ) { From a9118a8bccc03837b115d43c012d627fbc8fbe2a Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Mon, 17 Jun 2024 14:39:31 -0600 Subject: [PATCH 2/3] - fixes a bug where date picker fields were being returned incorrectly in some cases --- src/FieldConfig.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/FieldConfig.php b/src/FieldConfig.php index 67bf30a..655bbdd 100644 --- a/src/FieldConfig.php +++ b/src/FieldConfig.php @@ -541,20 +541,6 @@ static function ( $opt ) { $value = apply_filters( 'the_content', $value ); } - if ( ! empty( $acf_field_config['type'] ) && in_array( - $acf_field_config['type'], - [ - 'date_picker', - 'time_picker', - 'date_time_picker', - ], - true - ) ) { - if ( ! empty( $value ) && ! empty( $acf_field_config['return_format'] ) ) { - $value = gmdate( $acf_field_config['return_format'], strtotime( $value ) ); - } - } - if ( ! empty( $acf_field_config['type'] ) && in_array( $acf_field_config['type'], [ 'number', 'range' ], true ) ) { $value = (float) $value ?: null; } From e58bcdaab6810a27a4d85dbc325d2d347ea5d658 Mon Sep 17 00:00:00 2001 From: Jason Bahl Date: Tue, 18 Jun 2024 15:15:38 -0600 Subject: [PATCH 3/3] - simplify resolvers for DatePicker and DateTimePicker --- src/FieldType/DatePicker.php | 21 ++++----------------- src/FieldType/DateTimePicker.php | 15 +++------------ 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/src/FieldType/DatePicker.php b/src/FieldType/DatePicker.php index 32a7e41..c03c818 100644 --- a/src/FieldType/DatePicker.php +++ b/src/FieldType/DatePicker.php @@ -1,6 +1,7 @@ static function ( $root, $args, $context, $info, $field_type, FieldConfig $field_config ) { $value = $field_config->resolve_field( $root, $args, $context, $info ); - if ( empty( $value ) ) { - return null; - } - - $acf_field = $field_config->get_acf_field(); - - // Get the return format from the ACF Field - $return_format = $acf_field['return_format'] ?? null; - - if ( empty( $return_format ) ) { - return $value; - } - - $date_time = \DateTime::createFromFormat( $return_format . '|', $value ); + $timestamp = strtotime( $value ); - if ( empty( $date_time ) ) { + if ( false === $timestamp ) { return null; } - // appending '|' to the format prevents the minutes and seconds from being determined from the current time - return $date_time->format( \DateTimeInterface::RFC3339 ); + return gmdate( DateTimeInterface::RFC3339, $timestamp ); }, ] ); diff --git a/src/FieldType/DateTimePicker.php b/src/FieldType/DateTimePicker.php index c87c83f..5e4616f 100644 --- a/src/FieldType/DateTimePicker.php +++ b/src/FieldType/DateTimePicker.php @@ -29,22 +29,13 @@ public static function register_field_type(): void { return null; } - $acf_field = $field_config->get_acf_field(); + $timestamp = strtotime( $value ); - // Get the return format from the ACF Field - $return_format = $acf_field['return_format'] ?? null; - - if ( empty( $return_format ) ) { - return $value; - } - - $date_time = \DateTime::createFromFormat( $return_format, $value ); - - if ( empty( $date_time ) ) { + if ( false === $timestamp ) { return null; } - return $date_time->format( DateTimeInterface::RFC3339 ); + return gmdate( DateTimeInterface::RFC3339, $timestamp ); }, ] );