acf-to-rest-api
acf-to-rest-api copied to clipboard
Memory limit issue querying ACF Post Objects
I'm having an issue connecting to the wp-json/wp/v2/posts endpoint while using ACF post objects on my Wordpress site. I have a post object field set up to allow me to link to posts from other posts and pages. If I link to the same post object more than once, i.e if I select "Post 1" for the post object field on "Post 2" as well as "Post 3", I get the following error with wp_debug enabled:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 261904 bytes) in C:\Websites\Gatsby\wp-includes\class-wp-hook.php on line 203
I increased the memory limit but the issue remains.
I first discovered this as I was getting the following error using Gatsby.js to build a static site:
Path: /wp-json/wp/v2/posts?per_page=100&page=1
The server response was "500 Internal Server Error"
If I link to a post object only once in Wordpress, I can hit the api endpoint fine. The error only happens when I link to the same post object more than once from different posts/pages.
I'm also using the acf-to-rest-api-recursive plugin to allow me to query acf fields of post objects.
Originally posted here in Gatsby.js - #9144
Same issue here. Gatsby outputs:
GraphQLError: Cannot query field "allWordpressPost" on type "Query". Did you mean "allW ordpressPage", "allWordpressWpUsers", "allWordpressWpMedia", "allWordpressWpTypes", or "wordpressPage"?
It's happened because the relationship between the posts caused an infinite loop.
It's happened because the relationship between the posts caused an infinite loop.
Yeah also figured that out now.
@phoolto Did you implement any fix or just remove the relationship between the posts?
@phoolto Did you implement any fix or just remove the relationship between the posts?
The only thing needed is at least one post with a featured image or turn off the featured images completely. It would definitely be good to have that fixed in the plugin but for now this should help.
Hey, can you explain that? I also got the error using this code:
$ids = get_field( 'weinauswahl', 'option', true );
$query->set( 'post__in', $ids );