WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#26326 closed defect (bug) (duplicate)

wp_edit_posts_query() loads all the posts into memory for hierarchical post types causing memory exhaustion

Reported by: rodrigosprimo Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

wp_edit_posts_query() loads all posts and post metas into memory for hierarchical post types when only a few are actually used to generated the admin page that lists them (wp-admin/edit.php).

I run a site with 4000 hierarchical posts of a custom type but this number is growing. Each post has about 10 small post metas. It is not possible to load the wp-admin/edit.php for this post type on the production server because of a memory exhausted error. On the development server I was able to check that the peak memory usage for this page is 321MB.

This problem is related with the code below from wp_edit_posts_query():

        // Hierarchical types require special args.
        if ( is_post_type_hierarchical( $post_type ) && !isset($orderby) ) {
                $query['orderby'] = 'menu_order title';
                $query['order'] = 'asc';
                $query['posts_per_page'] = -1;
                $query['posts_per_archive_page'] = -1;
        }

Change History (1)

#1 @SergeyBiryukov
7 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #15459 and #20621.

Note: See TracTickets for help on using tickets.