WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 3 months ago

#24603 closed enhancement (fixed)

Introduce pre_move_uploaded_file filter to allow pre-processing of uploaded files

Reported by: ryan Owned by: DrewAPicture
Milestone: 4.9 Priority: normal
Severity: normal Version:
Component: Upload Keywords: has-patch
Focuses: Cc:

Description

This is handy for use in file replication plugins. We've been using this on wordpress.com for awhile for just that purpose.

Attachments (5)

24603.diff (961 bytes) - added by ryan 4 years ago.
24603.patch (872 bytes) - added by Mte90 15 months ago.
refreshed patch
24603.2.patch (1.3 KB) - added by Mte90 15 months ago.
working refreshed patch
24603.3.patch (1.5 KB) - added by Mte90 14 months ago.
added docs
24603.2.diff (2.3 KB) - added by DrewAPicture 3 months ago.

Download all attachments as: .zip

Change History (14)

@ryan
4 years ago

#1 @chriscct7
2 years ago

  • Keywords needs-refresh needs-docs added

@Mte90
15 months ago

refreshed patch

@Mte90
15 months ago

working refreshed patch

#2 @Mte90
15 months ago

  • Keywords dev-feedback added; needs-refresh removed

Ignore the 24603.patch this is a wrong testing patch, the real refreshed patch is 24603.2.patch.

#3 @Mte90
14 months ago

  • Keywords has-patch added

This ticket was mentioned in Slack in #docs by morganestes. View the logs.


14 months ago

#5 follow-up: @johnbillion
14 months ago

  • Keywords dev-feedback removed

@Mte90 Can you add a docblock for the new filter please?

@Mte90
14 months ago

added docs

#6 in reply to: ↑ 5 @Mte90
14 months ago

  • Keywords needs-docs removed

Replying to johnbillion:

@Mte90 Can you add a docblock for the new filter please?

Done, I don't know if I written in the best way.

This ticket was mentioned in Slack in #core by drew. View the logs.


3 months ago

#8 @DrewAPicture
3 months ago

  • Milestone changed from Awaiting Review to 4.9

@Mte90 Updated patch looks pretty good. There's just a couple things I wanted to note that I'll go ahead and fix on commit:

  • There should be a space between the DocBlock summary and description
  • In the case of "real" values like null we typically assign "pseudo-variables" in the DocBlock so as to best illustrate what the value to represents. In this case, we'll probably just reuse $move_new_file

#9 @DrewAPicture
3 months ago

  • Owner set to DrewAPicture
  • Resolution set to fixed
  • Status changed from new to closed

In 41258:

Filesystem: Introduce the pre_move_uploaded_file filter.

Passing a non-null value to the filter will prevent the uploaded file from being moved to the uploads directory for any of the functions leveraging _wp_handle_upload(), such as wp_handle_upload() or wp_handle_sideload().

Error reporting related to the file being moved will also be skipped.

Props ryan, Mte90.
Fixes #24603.

Note: See TracTickets for help on using tickets.