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:49:23 +0000 (18:49 +0000)
commit4b9317c97a9a09ef3fe58e2013d83aeb47daf064
tree712ac5ca649799dac938cc7d70b5a8e78319bfa0
parente1ceccda7242006d507f5d74ad2e29f94fb62e09
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