humanmade / humanmade/altis-cms

Viewing post list table with large number of hierarchical posts has unbounded query

Open
#763 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
PHP
Stars
46
Forks
4
Avg merge
14h 31m
Merged PRs (30d)
13

Description

[`wp_edit_posts_query()`](https://developer.wordpress.org/reference/functions/wp_edit_posts_query/) has an unbounded query that triggers when viewing a hierarchical post type; specifically, [this code](https://github.com/WordPress/wordpress-develop/blob/d1f73cd80fd38cfa014fbbb894d7f631bcdb658c/src/wp-admin/includes/post.php#L1278-L1285) sets `posts_per_page` to be unlimited and overrides the order, but only when no orderby is set.

This means page loads can take vast amounts of time, but if you click on the Date column to "reorder" the page, it's suddenly fast, even though it renders the same page.

I've checked and [VIP is overriding this when the page is loaded](https://github.com/Automattic/vip-go-mu-plugins/blob/ab1f0ac12b1690d27a175baac10729cc7a0060ff/performance/bulk-edit.php#L39-L42) so clearly they've hit this issue previously too - we should apply a similar workaround to ensure the query is not unbounded.

Steps to reproduce:
1. Create 100k+ pages or other hierarchical post type
2. Load the list table for the post type
3. Observe unbounded query in Query Monitor for the post

Acceptance criteria:

- [ ] ...

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.