Support

Account

Home Forums Add-ons Flexible Content Field Latest version: critical endless loop crashes sites Reply To: Latest version: critical endless loop crashes sites

  • Hi and Thanks for answering and for your time!
    To simplify a little:

    “note: you don’t need to specify the $post_id for any sub field functions”

    This is in your documentation, for the new version of ACF. We think this change is the problem.

    When we rolled back ACF one step, everything works again.

    The structure example posted before, is not a real function, just a ‘dummie’. Our setup is very complex and hard to explain. But I try:

    EVERY POST have the exact same ACF setup fields:

    The Repeater has a subfield with a Flexible content with layouts, and in one layout a relationship post object field.

    This is what we accomplish:

    Every post and page has the same Repeater. With this we build the content below the standard editor. And a post can include another post(s) repeater-content, and that post can include repeater-content from another post… No depth limit, but a post id can never be include itself in each chain.

    We are not using widets. We are using posts. Example: One post using ACF Gallery and location field (in the repeater). We wanna re-use this post as a widget.

    Example: The main query POST “Delayed travels” says (in the repeater):

    Include POST Gallery on Sidebar 2 on top, and
    Include POST Airport Links on Sidebar 3 …

    Then the latter POST Airport Links, says: (in its own repeater field)

    Include POST Airport Germany links on Below main content
    Include POST Airport Sweden links on Below main content
    Include POST Airport Sydney links on Below main content
    Include POST Airport New Zeeland links on Below main content

    This is done with a simple output strategy. The Main post ( the page ) is using the wp single.php template, and the loop. Thats where the reading of the ACF fields starts. But it passes the post ID to a FIRST function with its own scope. Every post object called from here are NOT using any templates for output the html. Its done in a second function who echoes out its HTML. If this has repeater content, this posts id are passing up to the FIRST function. Its standard script function pass to unique scope.

    The key is to pass the ID to the FIRST function that holds “while has subfield”, and all the stuff to see if any post objects are gonna be included after rendering its own content.

    This scope is not unique anymore, couse ACF starting to use sub fields from the loop (where it all begins). WE THINK…

    Here is the REAL PHP the beginning of the 2 main functions and the loop.

    
    //MAIN LOOP
    the_content();
    $extra_content = get_field('activate_content_below', get_the_ID());
    if($extra_content) whatever(get_the_ID()); 
    // END MAIN LOOP
    
    This is in functions.php
    // unique scope :
    function whatever($id){
    	while(has_sub_field('ua_acm_rf_master', $id)){
    		if(get_sub_field('ua_acm_rf_activate')){ // true or false switch
    			while(has_sub_field('ua_acm_rf_fc_master', $id)){
    				if(get_row_layout() == 'ua_acm_rf_fc_post_include'){ 
    					if(get_sub_field('posts')){
    						foreach(get_sub_field('posts') as $p){
    							$inc_id = $p->ID;
    							ua_post_this($inc_id); <-- REMARK NEW ID
    
    							
    // unique scope :							
    function ua_post_this($inc_id){
    	$obj = get_post( $inc_id );
    	echo '<h1>'.$obj->post_title ... and so on
    	
    	Now, we check if THIS post have som ACF field, calling the SAME function as the LOOP did.
    	$extra_content = get_post_meta($inc_id, 'activate_content_below', true); 
    	if($extra_content) whatever($inc_id); <-- RE-USING FIRST FUNCTION
    }
    

    Im shure its a small, tiny change like global $something that destroys this setup. But the worrying part is that we are completley building with ACF, and it is a Huge invested time in this modular building setup. We must get it to work and keep up with latest versions…

    Many many thanks for looking in to this.