Make WordPress Core


Ignore:
Timestamp:
07/28/2021 01:01:32 PM (3 years ago)
Author:
desrosj
Message:

Media: Check the posts_per_page value in wp_ajax_query_attachments() before using it as a divisor.

This avoids a "Division by zero" PHP warning if a plugin changes the posts_per_page value to zero.

Follow-up to [51145].

Props 2linctools, kapilpaul, audrasjb, SergeyBiryukov.
Merges [51485] to the 5.8 branch.
Fixes #53773.

Location:
branches/5.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.8

  • branches/5.8/src/wp-admin/includes/ajax-actions.php

    r51224 r51507  
    30043004    }
    30053005
    3006     $max_pages = ceil( $total_posts / (int) $attachments_query->query['posts_per_page'] );
     3006    $posts_per_page = (int) $attachments_query->query['posts_per_page'];
     3007
     3008    $max_pages = $posts_per_page ? ceil( $total_posts / $posts_per_page ) : 0;
    30073009
    30083010    header( 'X-WP-Total: ' . (int) $total_posts );
Note: See TracChangeset for help on using the changeset viewer.