media: Log and fail gracefully on invalid EXIF coordinates
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>
Tue, 26 Nov 2019 08:54:05 +0000 (09:54 +0100)
committerReedy <reedy@wikimedia.org>
Tue, 17 Dec 2019 18:42:24 +0000 (18:42 +0000)
commitfbc41be5483799894d3f03de3429df0a56dd8d36
tree5bd8b8020c3d4d4e6bd380d20365fdbd20d28b6d
parentc9c7e2e1ce2eeff68af47ffb5207716314363da1
media: Log and fail gracefully on invalid EXIF coordinates

The $coord value is a value extracted from the EXIF section of an
image file. We expect it to be a float, but there is no guarantee this
is the case. It could, for example, be an empty string.

I suggest this trivial fix. It does have the following effects:
* Instead of logging a PHP notice when floor() hits something that is
  not a number, I try to log something that's more useful for later,
  more in-depth debugging. Note this log call isn't necessarily meant
  to stay, but to find an even better fix for this issue.
* I return the string as it is. If it's "foo", the user will see "foo"
  instead of "0° 0′ 0″ N", which wasn't helpful.

Also note how wrong and misleading the PHPDoc block for this function
was.

Bug: T226751
Change-Id: I1ca98728de4113ee1ae4362bd3e62b425d589388
(cherry picked from commit f6787ede2db29fcc2c1923e23eaa2e9bf86522a1)
includes/media/FormatMetadata.php