wp-graphql / wp-graphql-acf

WPGraphQL for Advanced Custom Fields
https://wpgraphql.com/acf
627 stars 123 forks source link

Fix: Internal server error 500 for relationship to non-published post #301

Closed rsm0128 closed 3 years ago

rsm0128 commented 3 years ago

This PR fixes #300, #85, #100

If non-published post is set for relationship field, it causes 500 internal server error when users without role to see the post try to fetch the field.

In the PR #286, @matt-antone used a condition check $post_object->status === 'publish' to fix this issue. Instead of that, in this PR, I used WPGraphQL\Model\Model::get_visibility() function to check if the user have the proper permission to read the post.