[wp-trac] [WordPress Trac] #48605: add_magic_quotes() inappropriately recasts data types
WordPress Trac
noreply at wordpress.org
Mon Nov 25 11:11:09 UTC 2019
#48605: add_magic_quotes() inappropriately recasts data types
--------------------------+-----------------------------
Reporter: Veraxus | Owner: SergeyBiryukov
Type: defect (bug) | Status: reviewing
Priority: normal | Milestone: 5.4
Component: General | Version: trunk
Severity: major | Resolution:
Keywords: has-patch | Focuses:
--------------------------+-----------------------------
Comment (by jrf):
Replying to [comment:8 Rarst]:
> I don't know on top of my head, but is there (significant) loss of
precision if float is converted to string and back? Unlike integers,
floats do not necessarily map 1:1 to string representation.
>
> Not touching them in first place seems to be preferable approach to me,
over potentially lossy type juggling.
@Rarst Good point and thanks for asking this. Good to document the answer
as part of this ticket.
The short answer is: no, this won't be an issue.
The long answer:
* The loss of precision occurs when doing calculations like
multiplication/division, not when doing casts.
* The default `precision` ini value of PHP is 14 and WP doesn't change
that. This affects the value of `REQUEST_TIME_FLOAT` way before doing the
casts.
Evidence: https://3v4l.org/3dEnW
And yes, it would always be better not to touch the values in the first
place (aka: the second patch), but the first patch should work just fine
in this instance without significant loss of precision.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48605#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list