[wp-trac] [WordPress Trac] #54385: Fatal error uploading media on PHP8

WordPress Trac noreply at wordpress.org
Wed Nov 10 11:27:04 UTC 2021


#54385: Fatal error uploading media on PHP8
----------------------------+------------------------------
 Reporter:  stevegs         |       Owner:  adamsilverstein
     Type:  defect (bug)    |      Status:  assigned
 Priority:  normal          |   Milestone:  5.9
Component:  Media           |     Version:  2.5
 Severity:  normal          |  Resolution:
 Keywords:  php8 has-patch  |     Focuses:
----------------------------+------------------------------

Comment (by stevegs):

 Replying to [comment:14 adamsilverstein]:
 > [attachment:"Sugarloaf Mountain.jpg"] is a second sample image from
 @quantumzen that reproduces the issue (from
 https://core.trac.wordpress.org/ticket/54009).

 What a beautiful photo, Adam!

 Thanks guys.  For a temporary fix, I have changed my image.php file as
 follows:

 Old line 844:
   $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
 New line 844:
   $meta['aperture'] = round( (float) wp_exif_frac2dec( $exif['FNumber'] ),
 2 );

 and the original image now loads fine.

 I've noticed wp_exif_frac2dec() appears in 2 other locations in image.php:
 in both cases the return is locally cast to a string.  From my relatively
 newbie point of view, since this is an arithmetic function, it should
 always return a float.  It should then be the responsibility of anything
 that calls it to recast to a string (or whatever else) to suit its own
 purpose.  But then, as others have pointed out here, there is the risk
 something elsewhere that calls the function will break under PHP8 if it
 hasn't done any recasting required.  Happy grepping!

 Meanwhile, I have advised our photographer to bring her photos into
 Paintshop Pro, which strips out all the EXIF info, before uploading.

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


More information about the wp-trac mailing list