Support » Plugin: Advanced Custom Fields » [Plugin: Advanced Custom Fields] Sites with large DBs break the option screen

  • 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/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Advanced Custom Fields] Sites with large DBs break the option screen’ is closed to new replies.