[wp-trac] [WordPress Trac] #60835: Fix and improve handling of uploading of font files
WordPress Trac
noreply at wordpress.org
Fri Jul 12 23:13:17 UTC 2024
#60835: Fix and improve handling of uploading of font files
----------------------------------------------------+---------------------
Reporter: azaozz | Owner: (none)
Type: defect (bug) | Status: new
Priority: high | Milestone: 6.7
Component: Upload | Version: 6.5
Severity: normal | Resolution:
Keywords: needs-testing has-patch has-unit-tests | Focuses:
----------------------------------------------------+---------------------
Comment (by azaozz):
Replying to [comment:81 youknowriad]:
Thanks @youknowriad and @peterwilsoncc for the review.
> So to summarize, it seems the crux of the disagreement is whether we
think that opening an API for plugins to upload files to a folder of their
choosing knowing that they can already do it (in a less straightforward
way) is a big enough downside compared to the code quality improvement and
maintainability offered by the change in the PR.
>
> My opinion is still the same, I think the PR is worth it and the
downside is not big enough to prevent it from landing. I can understand
that folks may feel otherwise though.
Just a note that letting plugins (and core) have more granular control
when they are using `wp_upload_bits()`, etc. can also be seen as an
improvement, not as a downside? As mentioned above this seems to make
`wp_upload_bits()` a bit more useful to plugins, and has no backwards
compatibility concerns.
An alternative solution I was looking at was to "split" `wp_upload_bits()`
in two (similarly to `_wp_handle_upload()` and `wp_handle_upload()`):
- A new, private function that will have most of the existing code. It
will only have the `$upload_dir` parameter and will not use
`wp_upload_dir()`.
- The existing function would become a wrapper, will call
`wp_upload_dir()` and pass on the value to the new function.
Something like this (mostly pseudo-code):
{{{
#!php
function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '2.0.0' );
}
if ( empty( $name ) ) {
return array( 'error' => __( 'Empty filename' ) );
}
$upload_dir = wp_upload_dir( $time );
if ( false !== $upload_dir['error'] ) {
return $upload_dir;
}
return _wp_handle_sideload( $bits, $name, $upload_dir );
}
function _wp_handle_sideload( $file, $name, $upload_dir ) {
// Rest of the existing code from wp_upload_bits().
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/60835#comment:82>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list