Skip to content

Fixed 32-bit integer overflow by allowing UTCDateTime() to get it's own current time #1127

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 23, 2017

Conversation

macdabby
Copy link
Contributor

@macdabby macdabby commented Feb 23, 2017

@jenssegers This fixes the issue over on #1115

@macdabby
Copy link
Contributor Author

I ran tests with this code in the freshTimestamp() method:

    print new UTCDateTime().get;
    print "\n";
    print new UTCDateTime((int)round(microtime(true) * 1000));
    print "\n";

What's interesting is that the output was as follows:

1487777270195
1487777270195
1487777270197
1487777270197
1487777270197
1487777270197
1487777270197
1487777270198
1487777270197
1487777270198
1487777270198
1487777270198
1487777270198
1487777270198
1487777270198
1487777270199
1487777270198
1487777270199

In most cases, you'll see the matching pair, however in a few cases they were off by one second. I suppose that comes from rounding.

@jenssegers
Copy link
Contributor

Can you change src/Jenssegers/Mongodb/Auth/DatabaseTokenRepository.php as well?

@macdabby
Copy link
Contributor Author

Yeah, I also added an explicit null as a parameter to prevent notices. Tested to make sure I got the same output as above.

@jenssegers jenssegers merged commit db1c5ea into mongodb:master Feb 23, 2017
mnphpexpert added a commit to mnphpexpert/laravel-mongodb that referenced this pull request Sep 2, 2024
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.

2 participants