Make WordPress Core

Changeset 51485 for trunk


Ignore:
Timestamp:
07/25/2021 09:55:33 AM (3 years ago)
Author:
SergeyBiryukov
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.
Fixes #53773.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/ajax-actions.php

    r51224 r51485  
    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.