WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
Sites with large DBs break the option screen (3 posts)

  1. bytesmasher
    Member
    Posted 2 years ago #

    There's an issue with ACF when used on sites that have a large number of posts. The options screen attempts to pull back every post on the site to populate the "Posts" dropdown box in the "Location" options panel. It uses the following line of code to do so:

    foreach(get_posts(array('numberposts'=>'-1')) as $v)

    This seems to be be fine and well on most sites, as I don't see anyone else here complaining about this issue. My problem is, I have almost 10 thousand items in my wp_posts table, most of which are posts. This query in the Edit Field Group page completely chokes on my database and times out before it can get the data back to your plugin.

    At first I thought I had a horribly misconfigured MySQL installation, until I started debugging, and traced the problem to the fact that the update_post_caches routine was being called after pulling back 8000+ posts.

    I've already posted a ticket to core.trac, as I see this as a core bug of sorts, but there is something you (yes, I'm looking at you Elliot Condon) can do... actually, there are two things:

    1) Ask yourself: Why on earth pull back *every* single post on a site just to shove them all into a dropdown? Wouldn't it make infinite more sense to let people just type the post ID or permalink into a text box?

    2) Set the cache_results flag to false when performing the query that pulls back every bit of post content on a site for no good reason (as such):

    foreach(get_posts(array('numberposts'=>'-1','cache_results'=>false)) as $v)

    For those who are onlooking, option 2 is what you need to change to get this plugin to work in a data-intense environment. This line of code is contained in ./wp-content/plugins/advanced-custom-fields/core/admin/meta_box_location.php (The line number is somewhere close to 189 ... not sure as I was debugging and some blank lines may have gotten added or removed)

    http://wordpress.org/extend/plugins/advanced-custom-fields/

  2. elliotcondon
    Member
    Plugin Author

    Posted 2 years ago #

    Hi there

    Thanks for post. I think you will be interested in trsting the new beta here http://www.advancedcustomfields.com/support/discussion/1594/beta-acf-v3.1.6

    Lots of work has been done to boost performance on large sites

    Cheers
    E

  3. wpvince
    Member
    Posted 2 years ago #

    New version looking good.
    Can you also address the JS loading on every page issue as well in this version please?
    http://wordpress.org/support/topic/766986

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic