[wp-trac] [WordPress Trac] #54111: Delete attachment with sizes not working on Windows file system
WordPress Trac
noreply at wordpress.org
Sat Sep 11 16:01:47 UTC 2021
#54111: Delete attachment with sizes not working on Windows file system
--------------------------------+-----------------------------
Reporter: kybernetikservices | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.8.1
Severity: critical | Keywords:
Focuses: |
--------------------------------+-----------------------------
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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54111>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list