Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #54385, comment 16


Ignore:
Timestamp:
11/16/2021 09:29:27 PM (3 years ago)
Author:
stevegs
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #54385, comment 16

    initial v1  
    77
    88Old line 844:
    9   $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
     9`$meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );`
    1010New line 844:
    11   $meta['aperture'] = round( (float) wp_exif_frac2dec( $exif['FNumber'] ), 2 );
     11`$meta['aperture'] = round( (float) wp_exif_frac2dec( $exif['FNumber'] ), 2 );`
    1212
    1313and the original image now loads fine.
    1414
    15 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!
     15I've noticed wp_exif_frac2dec() appears in 2 other locations in image.php: in both these 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!
    1616
    1717Meanwhile, I have advised our photographer to bring her photos into Paintshop Pro, which strips out all the EXIF info, before uploading.