WordPress.org

Make WordPress Core

Opened 2 months ago

Closed 4 weeks ago

Last modified 3 weeks ago

#45707 closed task (blessed) (fixed)

Add parameter $real_mime to wp_check_filetype_and_ext

Reported by: Tkama Owned by: pento
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Upload Keywords: has-patch commit needs-dev-note
Focuses: Cc:

Description

In some cases, I need the parameter $real_mime in hook wp_check_filetype_and_ext. I don't see any reasons to not pass it there.

<?php
return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes, $real_mime );

Attachments (1)

45707.diff (1.8 KB) - added by desrosj 6 weeks ago.

Download all attachments as: .zip

Change History (15)

#1 @SergeyBiryukov
2 months ago

  • Component changed from General to Upload
  • Milestone changed from Awaiting Review to 5.1

This ticket was mentioned in Slack in #core-media by desrosj. View the logs.


6 weeks ago

#3 @desrosj
6 weeks ago

  • Keywords needs-patch added
  • Version 5.0.1 deleted

@desrosj
6 weeks ago

#4 @desrosj
6 weeks ago

  • Keywords has-patch added; needs-patch removed

#5 @joemcgill
6 weeks ago

  • Owner set to joemcgill
  • Status changed from new to accepted

Thanks @Tkama,

I think something like this could be really helpful for people trying to get around issues like #45615. I'm expecting to make some changes to the way this works in 5.1 so let's include this ticket in the process.

Cheers!

#6 @joemcgill
6 weeks ago

  • Type changed from enhancement to task (blessed)

If #40175 doesn't land in 5.1 (and maybe even if it does) we should do this to help folks experiencing issues like #45615 more easily filter wp_check_filetype_and_ext(). Going to mark this as task/blessed and revisit depending on #40175.

#7 @pento
5 weeks ago

Aye, this seems like a reasonable alternative to landing #40175 in 5.1.

This ticket was mentioned in Slack in #core-media by joemcgill. View the logs.


5 weeks ago

#9 @joemcgill
4 weeks ago

  • Keywords commit added

Let's go ahead and do this for 5.1.

#10 @pento
4 weeks ago

  • Owner changed from joemcgill to pento

#11 @pento
4 weeks ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 44677:

Media: Add a $real_mime parameter to the wp_check_filetype_and_ext filter.

This allows more accurate filtering of the filename and extension given to uploaded files.

Props desrosj, Tkama.
Fixes #45707.

#12 @pento
4 weeks ago

  • Keywords needs-dev-note added

@joemcgill, @desrosj: As this is the workaround for the #40175, it'd be good to have a dev note explaining how to use it.

#13 @joemcgill
4 weeks ago

@pento, @desrosj – I'll write a dev note.

This ticket was mentioned in Slack in #core-media by joemcgill. View the logs.


3 weeks ago

Note: See TracTickets for help on using tickets.