#54129 closed defect (bug) (fixed)
Undefined index 'posts_per_page' in ajax-actions.php
| Reported by: | davidwebca | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.8.2 |
| Component: | Media | Version: | 5.8 |
| Severity: | normal | Keywords: | has-patch needs-testing commit |
| Cc: | Focuses: |
Description
This is a follow-up to #53773.
The fix was unsifficient to prevent some errors, such as 'undefined index: posts_per_page' which I am getting right now on line 3006 in 5.8.1.
The problem comes from the fact that we are trying to get "posts_per_page" on the query sub-object directly instead of using getter methods on the WP_Query instance. With the getter methods of WP_Query, a default value is always provided if none is set by the user and defaults to 12 like the WordPress global posts_per_page value.
Line 3006 should be changed from
$posts_per_page = (int) $attachments_query->query['posts_per_page'];
to
$posts_per_page = (int) $attachments_query->get('posts_per_page');
Change History (9)
This ticket was mentioned in PR #1679 on WordPress/wordpress-develop by mukeshpanchal27.
5 years ago
#3
- Keywords has-patch added
Trac ticket: https://core.trac.wordpress.org/ticket/54129
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi there, welcome back to WordPress Trac! Thanks for the ticket.
Moving to 5.8.2, as this was introduced in [51145].