• Resolved Ahmed ElSayed

    (@a7madmayo)


    Hi,
    I have an issue with the Plugin as requests all forms on every page init which exhaust my hosting server, I just want to know why all of these queries in every page load and how to stop that?
    Thanks

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Mark Howells-Mead

    (@markhowellsmead)

    The plugin has to load all of the available forms when you enter the Edit Field Group screen in WordPress Admin, so that you can select the form which you want to include in the ACF output. This only has an effect in WordPress Admin, as this plugin has nothing to do with the frontend of the website. (Unless you’re using the acf_form function on public pages.)

    Thread Starter Ahmed ElSayed

    (@a7madmayo)

    Hi Mark,
    I think I wasn’t clear enough,

    Using Query Monitor, I found alot of queries executed on the homepage for example this query
    SELECT *
    FROM wp_6_gf_form
    WHERE id=2 /* https://www.edntaiwan.com/ */

    why these queries executed in homepage?
    Thanks

    Plugin Author Mark Howells-Mead

    (@markhowellsmead)

    I don’t know, sorry. That would most likely depend on the remainder of the code which you’re using on the website. This plugin doesn’t interfere with any content placed on the website. (Unless, as I wrote, you’re using the acf_form function on public pages.)

    Hi,

    we were able to reproduce this issue using version 1.2.7 and ACF Pro 5.9.4. I think the problem is that all forms are loaded in the __construct method of ACFGravityformsField\Field class:

    
    	public function __construct()
    	{
    		$this->name = 'forms';
    		$this->label = __('Forms', 'gravityforms');
    		$this->category = __('Relational', 'acf');
    		$this->defaults = [
    			'return_format' => 'form_object',
    			'multiple'      => 0,
    			'allow_null'    => 0
    		];
    
    		// Get our notices up and running
    		$this->notices = new Notices();
    
    		if (class_exists('GFAPI')) {
    			$this->forms = GFAPI::get_forms();
    		}
    
    		// Execute the parent constructor as well
    		parent::__construct();
    	}
    

    We fixed it temporarily by replacing the condition in __construct method:

    
    if (class_exists('GFAPI') && is_admin()) {
        $this->forms = GFAPI::get_forms();
    }
    

    Ideally $this->forms should be replaced with method which loads forms dynamically when needed.

    Plugin Author Mark Howells-Mead

    (@markhowellsmead)

    Please try version 1.2.8, which is now available in the plugin repository.

    Thread Starter Ahmed ElSayed

    (@a7madmayo)

    @all Thanks for your help

    Plugin Author Mark Howells-Mead

    (@markhowellsmead)

    Version 1.2.8 resolves this support request.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Plugin requests all forms on page init’ is closed to new replies.