#14627 closed defect (bug) (fixed)
wp_handle_upload unique_filename_callback problem
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.1 | Priority: | normal |
Severity: | major | Version: | 3.0.1 |
Component: | Upload | Keywords: | has-patch |
Focuses: | Cc: |
Description ¶
Right now I am using wp_handle_upload to upload a file and I would like to provide a custom filename using the unique_filename_callback parameter.
If you look at 3.0.1 wp-includes/functions.php line 2218 inside the wp_unique_filename function. You will see that $dir, $name are passed into the callback function. However, the $name parameter is the filename without the extension, so the only thing missing is $ext. A callback function is unable to generate a proper filename without the original ext the file is in.
Line 2218 needs to look like:
$filename = $unique_filename_callback( $dir, $name, $ext );
Pull Requests
- Loading…
Change History (6)
#2
@ Lead Developer
15 years ago
- Milestone changed from Awaiting Review to 3.1
- Owner set to nacin
- Status changed from new to accepted
Seems sane. We should probably also use call_user_func.
#3
@ Lead Developer
15 years ago
- Keywords has-patch added; needs-patch removed
Someone want to test this?
#5
@ Core Committer
15 years ago
Sorry, it looks like I uploaded a partial diff to #12824 and it only partially fixed the issue.
As for the patch, I tested it quickly and it works fine in my case. However, my problem had nothing to do with needing an extension. I just needed to be able to use a method in a class rather than a function.
I just found the exact same thing! Line 2218 in v3.0.1 of
/wp-includes/functions.php
has the following code:This is all that would be needed to "fix" this problem:
Adding a third parameter would enable a developer to return a working file.
As it, the 'unique_filename_callback' is pretty much unusable. This is teeny, tiny fix, please accept for v3.1.
-Mike