Skip to content

Commit

Permalink
Media: Cache parent posts in query-attachments AJAX endpoint.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
peterwilsoncc committed Aug 12, 2022
1 parent d7f5fe1 commit 0161ef8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions wp-admin/includes/ajax-actions.php
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Expand Up @@ -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.
Expand Down

0 comments on commit 0161ef8

Please sign in to comment.