Opened 10 years ago
Closed 10 years ago
#29919 closed defect (bug) (duplicate)
Admin posts overview (edit.php) for hierarchical custom post type loads all posts
Reported by: | engelen | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.0 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | administration, performance | Cc: |
Description
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.
Duplicate of #15459.