[wp-trac] [WordPress Trac] #34190: Function Reference/wp check filetype

WordPress Trac noreply at wordpress.org
Wed Oct 7 12:21:44 UTC 2015


#34190: Function Reference/wp check filetype
--------------------------+----------------------
 Reporter:  lpkapil       |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Media         |     Version:  4.3.1
 Severity:  normal        |  Resolution:  invalid
 Keywords:                |     Focuses:
--------------------------+----------------------
Changes (by chriscct7):

 * status:  new => closed
 * focuses:  accessibility, docs, administration, multisite, performance =>
 * severity:  critical => normal
 * component:  Administration => Media
 * milestone:  Awaiting Review =>
 * keywords:  needs-patch =>
 * resolution:   => invalid


Comment:

 The reason you are getting back false has nothing to do with the null
 seperator. Because you didn't specify an array of mime types for parameter
 2, WordPress looks for a mime type matching one of the acceptable
 WordPress mime types in get_allowed_mime_types(). .php is not an allowed
 mime type for uploads, and as a result, the function correctly returns the
 result of false. This is both expected and designed behavior

 Proof of concept:

 {{{
 wp_die( var_dump( 'test.jpg', wp_check_filetype( 'test.jpg' ),
 'test.php', wp_check_filetype( 'test.php' ), 'test.jpg.php',
 wp_check_filetype( 'test.jpg.php' ) ) );
 }}}


 Will return


 {{{
 string 'test.jpg' (length=8)

 array (size=2)
   'ext' => string 'jpg' (length=3)
   'type' => string 'image/jpeg' (length=10)

 string 'test.php' (length=8)

 array (size=2)
   'ext' => boolean false
   'type' => boolean false

 string 'test.jpg.php' (length=12)

 array (size=2)
   'ext' => boolean false
   'type' => boolean false

 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34190#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list