Opened 11 months ago
Last modified 11 months ago
#54111 new defect (bug)
Delete attachment with sizes not working on Windows file system
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | critical | Version: | 5.8.1 |
Component: | Media | Keywords: | |
Focuses: | Cc: |
Description
I wrote a custom plugin for importing data, including media files, from a CRM system. The media files are stored in a dedicated folder in wp-content/uploads
.
When I delete a custom post I do also delete the attached media files with
wp_delete_attachment()
.
I noted, on a Windows server, that just the primary image file will be deleted. All related image sizes are not deleted.
I debuged the function wp_delete_attachment_files()
in wp-includes/post.php
and figured out there is something wrong with the function path_join()
(see code line 6240).
Before path_join()
the variable $intermediate_file
is
E:/folder1/folder2/folder3/wp-content/uploads/extra-folder/91010/65535_49693031347_cd702ea089_h_1280_700_nofilter-300x164.jpg
.
It is the full windows path including file.
After $intermediate_file = path_join( $uploadpath['basedir'], $intermediate_file );
the variable $intermediate_file
is equal
E:/folder1/folder2/folder3/wp-content/uploads/E:/folder1/folder2/folder3/wp-content/uploads/extra-folder/91010/65535_49693031347_cd702ea089_h_1280_700_nofilter-300x164.jpg
Please check the path. It has added the full $intermediate_file
to the $uploadpath['basedir']
.
Same happen with the $intermediate_dir
. After usign path_join()
(line 6234) the path is
E:/folder1/folder2/folder3/wp-content/uploads/E:/folder1/folder2/folder3/wp-content/uploads/extra-folder/91010
As you can see, it is the $uploadpath['basedir']
followed by the full folder path.
The same code is working on a linux server as expected.
Please let me know if I can give you more details to reproduce and fix this error.
Thanks for all your effort.