Open DenislavPopov opened 5 months ago
Hey @DenislavPopov
As you noted, this is an issue with WPGraphQL for ACF and however they're resolving their date
field, so you should probably file an issue with them
(Marking as invalid?
- not because we think you're not experiencing a real issue, but simply because there's no way to address a potential bug in code that exists outside of this repo).
Hey @DenislavPopov, I transferred this issue over to WPGraphQL for ACF.
Hey @DenislavPopov, I transferred this issue over to WPGraphQL for ACF.
Great, thanks! 🍻 I was just about to create new issue there and saw it's there already
Hey @\DenislavPopov, I transferred this issue over to WPGraphQL for ACF.
Good to know we can do that for next time I send someone to do duplicate work 🤦
@DenislavPopov in my first attempt to reproduce, I was not able to. The date field nested within a flexible content layout is returning the date as expected:
I tried reproducing with the following:
I just tried with WPGraphQL for ACF v2.2.0 as well and same results. A date picker field within a flexible field layout is resolving as expected. Can you check to see that the values stored in the database are what you expect?
Also, can you share your ACF Field Group export to make sure I'm setting things up the same?
@DenislavPopov this logic looks like it might possibly be a culprit? https://github.com/wp-graphql/wpgraphql-acf/blob/develop/src/FieldType/DatePicker.php#L33-L38
@DenislavPopov here's how the data is stored when I tested:
I'm curious if the data is saving differently for you?
Hi @jasonbahl
Sending the info.
The database entry looks saved in the same format and also when reloading the post page the field is correctly populated with the saved data:
The GraphQL result:
Export of the fields from my end: acf-export-2024-06-10_Denis.json
Debugged the line pointed, and it looks like the format is correctly passed but the date received is not, hmm, will try to investigate further also.
Addition1: I can see the $root contains correct data, but then somehow the function resolve_field
returns the epoch time
Addition2: Compared the JSON exported files as with your import it works fine and narrowed it to the return format, which in my case is "return_format": "d\/m\/Y", while in your case is "return_format": "F j, Y",. So to narrow it down it looks it doesn't work only with the first return format:
@DenislavPopov I was able to reproduce when the return format is changed. Investigating this further.
Description
When ACF "Date Picker" field is used inside a "Flexible content" field, the returned value for this date field is always epoch time, disregarding the saved value. ( 1970-01-01T00:00:00+00:00 ).
Setup of the fields in ACF:
Saved settings on the page:
GraphQL result:
Steps to reproduce
Additional context
No response
WPGraphQL Version
1.27.0
WordPress Version
6.5.4
PHP Version
8.1.23
Additional environment details
WPGraphQL for ACF: version: 2.2.0
Please confirm that you have searched existing issues in the repo.
Please confirm that you have disabled ALL plugins except for WPGraphQL.