Repository navigation
Conversation
The Quick Edit and Bulk Edit parent drop-down on the Pages screen selected every column of every published page, including post_content, on every load of the screen. On sites with many or large pages this made the query slow and used a lot of memory. The `fields` argument of WP_Query now accepts an array of post field names. Only those fields and ID are selected. Unknown names are ignored. The partial post objects are not added to the post cache, and the loop still sets up full posts. get_pages() gains a `fields` argument that is passed to WP_Query, with post_parent, post_type and post_status always loaded. wp_dropdown_pages() also loads its `value_field`. The Quick Edit parent drop-down now loads every field except the long text columns.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
The Quick Edit and Bulk Edit parent drop-down on the Pages screen calls
get_pages(), which runsSELECT wp_posts.*for every published page on every load of the screen. The drop-down only needs a few fields, but the query also loadspost_contentand the other long text columns. On sites with many or large pages this is slow and uses a lot of memory.WP_Queryhas no way to select specific columns, so this PR adds one and uses it for the drop-down.Changes
WP_Query: thefieldsargument now also accepts an array of post field names.IDare selected. Unknown names are ignored, so arbitrary input never reaches the SQL.WP_Postobjects. Fields that weren't selected are empty.the_post()already loads the full post wheneverfieldsisn't'all'.get_pages(): new optionalfieldsargument, passed toWP_Query.post_parent,post_typeandpost_statusare always loaded, so hierarchy and functions likeget_permalink()keep working. It isn't added to the defaults, so the parsed arguments are unchanged for existing callers.wp_dropdown_pages(): adds itsvalue_fieldtofieldswhenfieldsis given.post_content,post_excerpt,post_content_filtered,to_pingandpinged.Code that doesn't pass
fieldsas an array behaves exactly as before, including caching.Performance
The drop-down query itself:
SELECT *)WP_Posts_List_Table::inline_edit():The drop-down HTML is identical to trunk at every size. Total
inline_edit()time is about the same, since building the<option>markup dominates.In the Quick Edit and Bulk Edit parent drop-down only,
get_pages/list_pagescallbacks receiveWP_Postobjects with emptypost_content,post_excerpt,post_content_filtered,to_pingandpinged. Plugins that need them can remove fields via thequick_edit_dropdown_pages_argsfilter.Trac ticket: https://core.trac.wordpress.org/ticket/54378
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Reproducing the issue, drafting the patch and tests. I reviewed, tested and edited the final implementation, tests and benchmarks.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.