[wp-trac] [WordPress Trac] #55688: Update size function in WP_Filesystem_Direct

WordPress Trac noreply at wordpress.org
Fri May 6 15:11:59 UTC 2022


#55688: Update size function in WP_Filesystem_Direct
--------------------------+---------------------
 Reporter:  mukesh27      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  6.0
Component:  Media         |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+---------------------

Comment (by SergeyBiryukov):

 Thanks for the PR!

 This change has backward compatibility concerns, as the method would no
 longer return `false` on failure, and it would not be possible to tell the
 difference between a file of 0 bytes or an error reading the file size.
 That might seem acceptable for media functions, for which `wp_filesize()`
 was introduced, but not for the `WP_Filesystem_*` classes, which are
 heavily used for updating plugins, themes, and WordPress core itself.

 So I'm not sure this should be changed at all, especially in 6.0, which is
 only two weeks away, and only regressions are addressed at this point.

 Frankly, I'm not a fan of the type casting to `int` in `wp_filesize()` and
 would prefer for it to mirror the native PHP function, with additional
 filters. However, it looks like it was suggested in comment:8:ticket:49412
 mostly for ease of use where the difference between a zero size and an
 error doesn't matter that much, and I can see that point as well.

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


More information about the wp-trac mailing list