Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #53773


Ignore:
Timestamp:
07/24/2021 04:38:22 PM (2 years ago)
Author:
SergeyBiryukov
Comment:

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

Introduced in [51145].

It looks like a plugin or theme changes the posts_per_page value to 0 using the ajax_query_attachments_args filter. By default, it's set to 40 in wp-includes/js/media-models.js.

We should be able to check the value and set $max_pages to 0 too in that case.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #53773

    • Property Keywords needs-patch good-first-bug added
    • Property Component changed from General to Media
    • Property Milestone changed from Awaiting Review to 5.8.1
  • Ticket #53773 – Description

    initial v1  
    11In the /wp-admin/includes/ajax-actions.php file line 3006 it keeps popping up an error in our php error log that says it is trying to divide by zero. It produces an error over and over again.
    2 
     2{{{
    33PHP Warning: Division by zero in /wp-admin/includes/ajax-actions.php on line 3006
    4 
     4}}}
    55This is line 3006:
     6{{{
    67$max_pages = ceil( $total_posts / (int) $attachments_query->query['posts_per_page'] );
    7 
     8}}}
    89
    910Here is the whole section:
     11{{{
    1012/**
    1113         * Filters the arguments passed to WP_Query during an Ajax
     
    4143        wp_send_json_success( $posts );
    4244}
    43 
     45}}}
    4446
    4547Our php error log looks like this: (truncated a lot)
    46 admin/includes/ajax-actions.php on line 3006
     48{{{
    4749[23-Jul-2021 18:46:05 UTC] PHP Warning:  Division by zero in  /wp-admin/includes/ajax-actions.php on line 3006
    4850[23-Jul-2021 18:46:14 UTC] PHP Warning:  Division by zero in  /wp-admin/includes/ajax-actions.php on line 3006
     
    5456[23-Jul-2021 19:35:58 UTC] PHP Warning:  Division by zero in  /wp-admin/includes/ajax-actions.php on line 3006
    5557[23-Jul-2021 19:36:01 UTC] PHP Warning:  Division by zero in  /wp-admin/includes/ajax-actions.php on line 3006
     58}}}