[wp-trac] [WordPress Trac] #54385: Fatal error uploading media on PHP8
WordPress Trac
noreply at wordpress.org
Tue Nov 23 13:14:19 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 needs-dev-note has- | Focuses:
unit-tests commit |
-------------------------------------------------+-------------------------
Comment (by stevegs):
Replying to [comment:37 adamsilverstein]:
> In [attachment:"54385.12.diff"], improve docblock:
> * Add string to return types.
> * Document input string.
Just allowing a string to be returned will not, on its own, fix the
original error I reported: namely line 844 of image.php expects a numeric.
So it would become the responsibility of the calling function to cast
appropriately.
My Olympus camera can report a shutter speed in several formats, eg. 1/60
(as normally expected, for speeds significantly <1sec), 1/2.5 (a hybrid
fraction for speeds near 1sec) and 4" (double-quote appended and no
foreslash for >1sec). The first two would be returned after performing
the division function; the last would be returned as a string - so that
must be catered for.
Although division by zero must be trapped, if both `$numerator` and
`$denominator` are numeric, a number should be returned IMO. Question is
what? Mathematically, it should be a very large number - and the sign of
the numerator should be preserved - eg. `gmp_sign($numerator) * 1e9` would
be a reasonable approximation. Alternative, but not mathematically
correct, returns could be 0 (zero) or simply `$numerator` (ie.
`$denominator` is set to 1). Though I suspect cameras that return (eg.)
0/0 have not recorded shutter speed, in which case a return of 0 would be
appropriate (but certainly not a string or a NULL). Other EXIF
information includes aperture, usually expressed in the form 'f/2.8'. But
I have seen entries in EXIF tables of 'f/NaN'...
So should we step back and consider what we are trying to achieve with
this function? Trying to be 'all things to all men' adds huge
complication. But if image.php is just being used to generate various
sizes of images for quicker downloading to web browsers (as it is in my
case), no EXIF info is needed at all.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54385#comment:40>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list