[wp-trac] [WordPress Trac] #46346: WP_List_Table calculates total_pages as a float
WordPress Trac
noreply at wordpress.org
Wed Feb 5 03:48:50 UTC 2020
#46346: WP_List_Table calculates total_pages as a float
----------------------------+------------------------------
Reporter: lev0 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Administration | Version:
Severity: minor | Resolution:
Keywords: has-patch | Focuses:
----------------------------+------------------------------
Comment (by lev0):
How about this updated, less "magic" version?
{{{#!patch
--- a/wp-admin/includes/class-wp-list-table.php
+++ b/wp-admin/includes/class-wp-list-table.php
@@ -284,7 +284,12 @@
);
if ( ! $args['total_pages'] && $args['per_page'] > 0 ) {
- $args['total_pages'] = ceil( $args['total_items']
/ $args['per_page'] );
+ $remainder = $args['total_items'] %
$args['per_page'];
+ if ( $remainder ) {
+ $args['total_pages'] = 1 + (
$args['total_items'] - $remainder ) / $args['per_page'];
+ } else {
+ $args['total_pages'] =
$args['total_items'] / $args['per_page'];
+ }
}
// Redirect if page number is invalid and headers are not
already sent.
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46346#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list