Opened 4 years ago
Last modified 2 weeks ago
#55376 new enhancement
Use wp_filesize in core
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Future Release | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | General | Keywords: | good-first-bug has-patch changes-requested |
| Focuses: | Cc: |
Attachments (1)
Change History (19)
This ticket was mentioned in PR #2402 on WordPress/wordpress-develop by Chargnn.
4 years ago
#2
- Keywords has-patch added; needs-patch removed
Replaced usage of filesize functions to wp_filesize in wp-admin/theme-editor.php
Trac ticket: https://core.trac.wordpress.org/ticket/55376
spacedmonkey commented on PR #2402:
4 years ago
#5
Thanks @Chargnn for the patch. I have added some links other places where this function can be used.
#6
in reply to:
↑ 5
@
4 years ago
Replying to spacedmonkey:
comment
1067905355
}}}
spacedmonkey commented on PR #2402:
I would consider using this function in the following places.
Thank you! Looking into this right now.
#8
in reply to:
↑ 4
@
4 years ago
Replying to spacedmonkey:
I would suggest not to use wp_filesize() in WP_Filesystem_* classes or other mission-critical parts like the update_core() function, due to backward compatibiltity concerns. See the discussion in comment:2:ticket:55688.
Using wp_filesize() in other instances seems fine at a glance.
#9
@
4 years ago
Thanks, @spacedmonkey for your advice, I followed your instruction and changed the filesize() function in the rest of the files.
#10
@
3 years ago
- Keywords needs-patch needs-refresh added; has-patch removed
@nihar007 This patch needs a refresh.
This ticket was mentioned in PR #4361 on WordPress/wordpress-develop by @spacedmonkey.
3 years ago
#11
- Keywords has-patch added; needs-patch needs-refresh removed
Trac ticket: https://core.trac.wordpress.org/ticket/55376
@spacedmonkey commented on PR #4361:
3 years ago
#12
Fixed
This ticket was mentioned in PR #7818 on WordPress/wordpress-develop by @ankitkumarshah.
19 months ago
#13
Trac ticket: https://core.trac.wordpress.org/ticket/55376
This PR replaces the use of filesize() with wp_filesize() in file.php and class-snoopy.php. The wp_filesize() function provides better handling for file size operations. This ensures improved compatibility and consistency with WordPress core standards.
#14
@
12 months ago
- Keywords needs-refresh changes-requested added
I reviewed @ankitkumarshah's PR on GitHub. To summarize here:
- The PR does not address all occurrences of
filesize()(minus the file system/update related ones noted by @SergeyBiryukov above). - Changes an instance within the
class-snoopy.phpfile, which has been deprecated since WP3.0. There's on benefit to updating this file.
@ankitkumarshah commented on PR #7818:
12 months ago
#15
Thank you for the feedback, @desrosj! I’ll make the suggested updates and refresh the PR shortly. 🙌
@ankitkumarshah commented on PR #7818:
12 months ago
#16
Hi @desrosj,
Thank you for the feedback! I’ve made the changes noted by @spacedmonkey in his comment on the Trac ticket. The following files were updated:
src/wp-admin/includes/file.phpsrc/wp-admin/includes/ms.phpsrc/wp-admin/includes/plugin.phpsrc/wp-includes/class-wp-customize-manager.phpsrc/wp-includes/ms-files.phpsrc/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.phpsrc/wp-includes/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php
Please review the PR at your convenience. Thank You 🙌
#17
@
12 months ago
Hi @desrosj,
Thank you for the feedback. I’ve made the necessary changes as requested. Please let me know if there’s anything else you’d like me to address.
This ticket was mentioned in PR #11990 on WordPress/wordpress-develop by @orionaselite.
2 weeks ago
#18
- Keywords needs-refresh removed
This PR replaces direct filesize() calls with wp_filesize() in core WordPress files where the wrapper function is appropriate. The wp_filesize() function (introduced in 5.7 via r52837) provides int casting and filter support, making it the preferred API for getting file sizes in WordPress.
## Files changed
src/wp-admin/includes/file.php—_wp_handle_upload()file size checksrc/wp-admin/includes/ms.php—check_upload_size()file size checksrc/wp-admin/includes/plugin.php—get_mu_plugins()index.php size checksrc/wp-admin/theme-editor.php— file size checks for theme file readingsrc/wp-includes/class-wp-customize-manager.php—_validate_header_video()video size validationsrc/wp-includes/functions.php—recurse_dirsize()directory size calculationsrc/wp-includes/ms-files.php—Content-Lengthheader for multisite file servingsrc/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php— upload space checksrc/wp-includes/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php—Content-Lengthheader for export
## Excluded (per reviewer feedback)
Per comment:8 by @SergeyBiryukov, filesystem abstraction and update/auto-update code should not be changed:
class-wp-filesystem-*— filesystem abstraction classes should use raw PHPfilesize()update-core.php— update/auto-update code excluded- Third-party libraries (Snoopy, pclzip, getid3, sodium_compat, ftp) — not WordPress core code
This addresses the feedback from @desrosj on PR #7818 requesting the additional instances noted by @spacedmonkey in comment:4.
CC @flixos90