[wp-trac] [WordPress Trac] #29919: Admin posts overview (edit.php) for hierarchical custom post type loads all posts

WordPress Trac noreply at wordpress.org
Fri Oct 10 12:43:36 UTC 2014


#29919: Admin posts overview (edit.php) for hierarchical custom post type loads all
posts
-----------------------------------------+-----------------------------
 Reporter:  engelen                      |      Owner:
     Type:  defect (bug)                 |     Status:  new
 Priority:  normal                       |  Milestone:  Awaiting Review
Component:  Administration               |    Version:  4.0
 Severity:  normal                       |   Keywords:
  Focuses:  administration, performance  |
-----------------------------------------+-----------------------------
 It seems as though the admin posts overview for hierarchical post types
 loads all available posts for the post type through `WP_Query`.
 Backtracing from `WP_Posts_List_Table::prepare_items` leads to
 `wp_edit_posts_query` in `wp-admin/includes/post.php`, which has at the
 end of the function.


 {{{
         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;
         }
 }}}

 It stems from the original `edit-pages.php` file, which was merged in 2010
 (https://github.com/WordPress/WordPress/commit/05bf7382ff9a02837cf15030689bd6c613927c01).

 So, basically, for hierarchical post types, '''the posts overview loads
 all posts from the database''' (or from cache). Has this ever come up
 before in Trac ([it has in forums](https://wordpress.org/support/topic
 /why-is-wp_edit_posts_query-queryposts_per_page-1?replies=5))? It seems
 incredibly inefficient and could possibly slow down (or bring down)
 servers.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29919>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list