Make WordPress Core


Ignore:
Timestamp:
02/17/2024 03:22:37 PM (10 months ago)
Author:
swissspidy
Message:

General: Consistently cast return value to int in functions that use ceil().

The return value of ceil() is still of type float as the value range of float is usually bigger than that of int.

Props crstauf, audrasjb.
Fixes #58683.

File:
1 edited

Legend:

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

    r57545 r57648  
    562562                /* translators: %s: Number of comments. */
    563563                'total_items_i18n'     => sprintf( _n( '%s item', '%s items', $total ), number_format_i18n( $total ) ),
    564                 'total_pages'          => ceil( $total / $per_page ),
    565                 'total_pages_i18n'     => number_format_i18n( ceil( $total / $per_page ) ),
     564                'total_pages'          => (int) ceil( $total / $per_page ),
     565                'total_pages_i18n'     => number_format_i18n( (int) ceil( $total / $per_page ) ),
    566566                'total'                => $total,
    567567                'time'                 => $time,
     
    30903090    $posts_per_page = (int) $attachments_query->get( 'posts_per_page' );
    30913091
    3092     $max_pages = $posts_per_page ? ceil( $total_posts / $posts_per_page ) : 0;
     3092    $max_pages = $posts_per_page ? (int) ceil( $total_posts / $posts_per_page ) : 0;
    30933093
    30943094    header( 'X-WP-Total: ' . (int) $total_posts );
    3095     header( 'X-WP-TotalPages: ' . (int) $max_pages );
     3095    header( 'X-WP-TotalPages: ' . $max_pages );
    30963096
    30973097    wp_send_json_success( $posts );
Note: See TracChangeset for help on using the changeset viewer.