[wp-trac] [WordPress Trac] #46346: WP_List_Table calculates total_pages as a float

WordPress Trac noreply at wordpress.org
Tue Jan 26 21:44:02 UTC 2021


#46346: WP_List_Table calculates total_pages as a float
----------------------------+-----------------------------
 Reporter:  lev0            |       Owner:  SergeyBiryukov
     Type:  defect (bug)    |      Status:  reviewing
 Priority:  normal          |   Milestone:  5.7
Component:  Administration  |     Version:
 Severity:  minor           |  Resolution:
 Keywords:  has-patch       |     Focuses:
----------------------------+-----------------------------

Comment (by jrf):

 > Please no. This is exactly problem, both are functions that return
 floats where people expect ints, and are still vulnerable to integer
 truncation. Also, the round() does nothing except waste cycles because
 ceil() has already found the float value nearest to the expected int.

 The thing is: **there is no problem** other than the return type being
 unexpected.

 The "problem" you suggest **only** exist for calculations with floats with
 decimals. As the base values being used **don't** have decimals, the
 problem you ''suggest'' this code has, doesn't actually exist.


 Note: making the code more complex and adding more calculation steps (like
 in the original patch) ''does'' cause for the code to become subject to
 the problem.

 And please, I'd love to be wrong, but as I said, show me one test case
 where with this use-case and code, the rounding problem would actually
 exist...

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46346#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list