Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#54129 new defect (bug)

Undefined index 'posts_per_page' in ajax-actions.php

Reported by: davidwebca Owned by:
Milestone: 5.8.2 Priority: normal
Severity: normal Version: 5.8
Component: Media Keywords: has-patch
Focuses: Cc:


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'];


$posts_per_page = (int) $attachments_query->get('posts_per_page');

Change History (5)

#1 @SergeyBiryukov
5 weeks ago

  • Milestone changed from Awaiting Review to 5.8.2

Hi there, welcome back to WordPress Trac! Thanks for the ticket.

Moving to 5.8.2, as this was introduced in [51145].

#2 @SergeyBiryukov
5 weeks ago

  • Version set to 5.8

This ticket was mentioned in PR #1679 on WordPress/wordpress-develop by mukeshpanchal27.

5 weeks ago

  • Keywords has-patch added

#4 @mukesh27
5 weeks ago

PR added with required change.

Feel free to update

This ticket was mentioned in Slack in #core-media by antpb. View the logs.

5 weeks ago

Note: See TracTickets for help on using tickets.