[wp-trac] [WordPress Trac] #54129: Undefined index 'posts_per_page' in ajax-actions.php
WordPress Trac
noreply at wordpress.org
Wed Sep 15 21:50:05 UTC 2021
#54129: Undefined index 'posts_per_page' in ajax-actions.php
--------------------------+-----------------------------
Reporter: davidwebca | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version:
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
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
{{{#!php
$posts_per_page = (int) $attachments_query->query['posts_per_page'];
}}}
to
{{{#!php
$posts_per_page = (int) $attachments_query->get('posts_per_page');
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54129>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list