airesvsg / acf-to-rest-api-recursive

Get ACF fields recursively
43 stars 8 forks source link

Need to handle infinite loops #2

Open jmikrut opened 6 years ago

jmikrut commented 6 years ago

Hi, thanks for this plugin - it's simple and super helpful.

One thing I noticed is that if an admin on a WP site using this plugin accidentally adds an ACF Relationship field to the same post that they are working with, the REST API response breaks and runs into an infinite loop situation.

Should be a similar fix I'd imagine to make sure that this is avoided. If I have time I will try to crack in and make a pull request. In the meantime I thought I'd let you know!

andrew-boyd commented 5 years ago

@jmikrut Our team ran into the same issue. Our attempt to address it can be seen in PR #3

adamk22 commented 5 years ago

I ran into an issue where my rest api would give a SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data wp rest response.

The page gave the following error:

<br />
<b>Fatal error</b>:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in <b>/srv/www/test-wp/public_html/wp-content/plugins/acf-to-rest-api-recursive-master/library/class-acf-to-rest-api-recursive.php</b> on line <b>56</b><br />
<br />
<b>Fatal error</b>:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in <b>/srv/www/test-wp/public_html/wp-includes/wp-db.php</b> on line <b>1889</b><br />

The fix @andrew-boyd supplied in his Pull Request solved this issue.

Kohrak commented 5 years ago

Hi, thanks for this plugin - it's simple and super helpful.

One thing I noticed is that if an admin on a WP site using this plugin accidentally adds an ACF Relationship field to the same post that they are working with, the REST API response breaks and runs into an infinite loop situation.

Should be a similar fix I'd imagine to make sure that this is avoided. If I have time I will try to crack in and make a pull request. In the meantime I thought I'd let you know!

Can I ask you how did you manage to set it up? @jmikrut