-
Notifications
You must be signed in to change notification settings - Fork 466
fix: post meta array on preview #3422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: post meta array on preview #3422
Conversation
…ew meta When $single is true, WordPress core's get_post_metadata filter returns the first value from an array. This fix ensures proper array wrapping to maintain expected behavior in GraphQL preview requests. Ref: https://github.com/WordPress/wordpress-develop/blob/2fe26ceb7a1f3fb57ec8726fc5f425d00a12ace9/src/wp-includes/meta.php#L666
|
@PatelUtkarsh thanks for this PR! Would you have any interest in contributing a test for this? An ideal test would be one that makes a preview query that includes meta and fails without this fix in place but passes with this fix in place. |
|
@jasonbahl I've added tests in latest commit. |
|
Thanks @PatelUtkarsh! 🙌🏻 |
|
Hello @jasonbahl, I couldn't figure out how to run the specific file / method in the setup, I tried setting up SUITS env. Do you have any advice on that? |
|
super close! Instead of |
What does this implement/fix? Explain your changes.
When meta is stored as serialize array in post meta table, during preview instead of returning array it returns first value from array.
When
$singleis true, WordPress core'sget_post_metadatafilter returns the first value from an array. This fix ensures proper array wrapping to return array back when stored value is array.Ref: https://github.com/WordPress/wordpress-develop/blob/2fe26ceb7a1f3fb57ec8726fc5f425d00a12ace9/src/wp-includes/meta.php#L666
Does this close any currently open issues?
Any other comments?