Support

Account

Home Forums Bug Reports Handling non-existent fields without infinite load and php memory limit issues

Solving

Handling non-existent fields without infinite load and php memory limit issues

  • This is a very particular edge-case bug report, but I thought it was worth putting out there in case the devs want to look at it.

    The issue occurs when I make a field (say a simple text input) and use it, put values in it, use get_field() in a template, etc

    Later, I decide that field should actually be a repeater so I go in and update the field type.

    Even later, I get around to wanting to update the template that field is used on, and I forget that I changed the type of field, so my template is still using get_field() instead of the proper have_row/the_row setup.

    The problem arises in that in this condition, ACF seems to go into some sort of infinite loop and eventually hits the PHP memory limit attempting to run get_field() on a field that is now a repeater.

    On one hand, this is 100% user error and not really the fault of ACF. On the other hand, I would kind of expect get_field() to have some kind of safe guard in place to detect a mis-match with the field calling method, and simple display nothing and maybe throw an error to the error log with a clue to the issue.

    Thanks for listening!

  • The devs don’t visit here, this is a user forum. For the devs to look at this you’d need to contact them or open a ticket in your account.

    I can’t fix the problem but I can tell you what I think is happening.

    Let’s say that you change a text field into a repeater.

    The value of the text field would of course be a text value like “this is text”. A repeater field (in the db) will contain the number of rows in the repeater. The issue would only happen if the field type was changed but a post using the field was not updated and would likely happen with get_field() or a have_rows() loop.

    Basically, acf gets the repeater row count, I don’t know if there is any checking to make sure the value is an integer. But what could be happening is something like

    
    for (i=0; $i<"this is text"; i++)
    

    Some very strange things can happen depending on what characters are in the string when it is converted to a number for the comparison, and other field types would have very different results.

  • I think your hypothesis is perhaps correct, thanks for that!

    I’ll reach out to them to see if they care or not, haha. There was a “Bug report” tag here so I thought maybe a pipeline had been setup for that sort of thing, but no worries.

    Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.