Media: Use `WP_Query::get()` method to retrieve the `posts_per_page` value in `wp_ajax_query_attachments()`.

This avoids a PHP notice and ensures that a default value is always provided if none is set by the user.

Follow-up to [51145], [51485].

Props davidwebca, mukesh27, circlecube, desrosj.
Merges [51982] to the 5.8 branch.
Fixes #54129.
Built from https://develop.svn.wordpress.org/branches/5.8@51983


git-svn-id: http://core.svn.wordpress.org/branches/5.8@51572 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-11-02 18:33:59 +00:00
parent dd352f4d54
commit fb283a3c27
2 changed files with 2 additions and 2 deletions

View File

@ -3003,7 +3003,7 @@ function wp_ajax_query_attachments() {
$total_posts = $count_query->found_posts;
}
$posts_per_page = (int) $attachments_query->query['posts_per_page'];
$posts_per_page = (int) $attachments_query->get( 'posts_per_page' );
$max_pages = $posts_per_page ? ceil( $total_posts / $posts_per_page ) : 0;

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.8.2-alpha-51981';
$wp_version = '5.8.2-alpha-51983';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.