WordPress.org

Make WordPress Core

Opened 6 weeks ago

Last modified 5 weeks ago

#43990 assigned enhancement

Use wp_delete_file instead of unlink

Reported by: macbookandrew Owned by:
Milestone: Future Release Priority: low
Severity: normal Version:
Component: Filesystem API Keywords: needs-testing has-patch
Focuses: Cc:

Description

Use wp_delete instead of unlink as much as possible throughout the codebase.

Attachments (1)

43990.patch (6.6 KB) - added by macbookandrew 6 weeks ago.

Download all attachments as: .zip

Change History (8)

@macbookandrew
6 weeks ago

#1 @jdgrimes
6 weeks ago

  • Summary changed from Use wp_delete instead of unlink to Use wp_delete_file instead of unlink

#2 @iandunn
6 weeks ago

#44014 was marked as a duplicate.

#3 @iandunn
6 weeks ago

  • Milestone changed from Awaiting Review to Future Release
  • Owner set to iandunn
  • Priority changed from normal to low
  • Status changed from new to accepted
  • Type changed from defect (bug) to enhancement

43990.patch looks pretty good at first glance. wp_delete_file() uses the @ operator when it calls unlink(), so I don't think we need to keep it when calling wp_delete_file().

( I kinda think it shouldn't even be used inside wp_delete_file(), but that's another ticket :) )

#4 @macbookandrew
6 weeks ago

I wondered about the @ operator but figured I’d leave it since I don’t know why it was there in the first place. 😄

#5 @desrosj
6 weeks ago

@macbookandrew just for clarity, can you quickly detail why using wp_delete_file() is preferred?

#6 @macbookandrew
6 weeks ago

@desrosj Basically to standardize on one method for removing files, and also giving the option to use the wp_delete_file filter for every file deletion action.

That and @iandunn’s comment here: https://core.trac.wordpress.org/ticket/43546#comment:57

#7 @iandunn
5 weeks ago

  • Owner iandunn deleted
  • Status changed from accepted to assigned
Note: See TracTickets for help on using tickets.