[wp-trac] [WordPress Trac] #53121: wp_get_image_mime() - something weird going on

WordPress Trac noreply at wordpress.org
Fri Apr 30 17:29:42 UTC 2021

#53121: wp_get_image_mime() - something weird going on
 Reporter:  jrf           |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:  4.8
 Severity:  minor         |   Keywords:
  Focuses:                |
 Okay, eh... help... so this is a weird one to write up.

 In the context of #53009, @hellofromTonya and me are looking at all calls
 to `markTestSkipped()` in the test suite.

 One of the ones I was looking at is this test in
 public function test_wp_get_image_mime( $file, $expected ) {
         if ( ! is_callable( 'exif_imagetype' ) && ! function_exists(
 'getimagesize' ) ) {
                 $this->markTestSkipped( 'The exif PHP extension is not
 loaded.' );

         $this->assertSame( $expected, wp_get_image_mime( $file ) );

 for the
 `wp_get_image_mime()`] function.

 Now, there are two questions I have:
 1. Why is `is_callable()` used for `exif_imagetype` and
 `function_exists()` for `getimagesize` ? This is the same in the actual
 function as well as the test, but strikes me as odd. Why not use
 `function_exists()` (or `is_callable()`) for both ?
 2. I've been trying to verify the conditions by running the test with the
 Exif and GD extensions in various states - both enabled, GD disabled -
 Exif enabled, GD enabled - Exif disabled, both disabled - and I can only
 seem to make the test hit the skip condition with Exif disabled. Tested on
 both PHP 5.6 as well as PHP 7.4.

 I've checked the PHP docs and the
 [https://www.php.net/manual/en/function.getimagesize.php `getimagesize()`]
 function is listed as part of the GD extension and the manual doesn't say
 anything explicitly about it being available independently of the
 extension, so the condition ''seems'' justified, but the fact that I can't
 seem to get the test to fail is making me want to dig deeper.

 Related to #11946 and #40017. The original function was introduced in
 [39831], the tests in [40397].

 Pinging @joemcgil - would you happen to be able to give me some insight
 into what's happening here ?

Ticket URL: <https://core.trac.wordpress.org/ticket/53121>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list