Media: Cache parent posts in query-attachments AJAX endpoint.

Prime the parent post objects `wp_ajax_query_attachments()` to reduce the number of database queries in the query-attachments admin-ajax endpoint.

Props albatross10.
Fixes #56037.


Built from https://develop.svn.wordpress.org/trunk@53885


git-svn-id: http://core.svn.wordpress.org/trunk@53444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2022-08-12 00:17:07 +00:00
parent d7f5fe1283
commit 0161ef8f72
2 changed files with 2 additions and 1 deletions

View File

@ -3038,6 +3038,7 @@ function wp_ajax_query_attachments() {
*/
$query = apply_filters( 'ajax_query_attachments_args', $query );
$attachments_query = new WP_Query( $query );
update_post_parent_caches( $attachments_query->posts );
$posts = array_map( 'wp_prepare_attachment_for_js', $attachments_query->posts );
$posts = array_filter( $posts );

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-53884';
$wp_version = '6.1-alpha-53885';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.