Skip to content

Fixed "Error parsing [float] as 64-bit integer" in Model::freshTimestamp() #1115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2017

Conversation

macdabby
Copy link
Contributor

Fixes an error when round(microtime(true) * 1000) works out to be a float. Running in HHVM 3.15.4

#712

@jenssegers
Copy link
Contributor

Can you change the casting to (int)?

@macdabby
Copy link
Contributor Author

Absolutely - done!

@jenssegers jenssegers merged commit 88d53cc into mongodb:master Feb 15, 2017
@ghobaty
Copy link

ghobaty commented Feb 23, 2017

@jenssegers @macdabby 4 byte integer overflow?!

microtime(true) = 1487826998.2899
microtime(true) * 1000 = 1487826998289.9
round(microtime(true) * 1000) = 1487826998290
(int) round(microtime(true) * 1000) = 1768313874

new UTCDateTime((int) round(microtime(true) * 1000)) will evaluate to a 1970-ish date.

@macdabby
Copy link
Contributor Author

macdabby commented Feb 23, 2017

It looks like 32bit PHP will overflow as you are experiencing. It also looks like a float should work with this function, and this is more likely a bug in HHVM. I'll create a PR to revert this change.

@macdabby
Copy link
Contributor Author

This function should also accept null to use the current time. @jenssegers should we use that instead?

@jenssegers
Copy link
Contributor

jenssegers commented Feb 23, 2017

@macdabby Wow, why didn't we see that. Are you up for making a PR? I'll get it merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants