Closed jmikola closed 1 year ago
@jmikola related JIRA ticket was made for legacy driver, is this something new one is tackling/will tackle?
related JIRA ticket was made for legacy driver, is this something new one is tackling/will tackle?
MongoDB\BSON\UTCDateTime::__construct()
accepts a string argument since 1.0.0, which will be parsed as a 64-bit integer.
It's almost 2018 and I'm very willing to close this and ignore 32-bit platforms (sorry @jwage).
@jmikola I didn't quite get whether ext-mongodb still has the same problem - now that dev-master uses ext-mongodb this might no longer be an issue.
I didn't quite get whether ext-mongodb still has the same problem - now that dev-master uses ext-mongodb this might no longer be an issue.
Looking at DateType
, I believe the issue still remains, as you cast a concatenated string of seconds and milliseconds to an integer.
An easy and portable fix would be to simply pass the DateTime object to UTCDateTime::__construct()
, which has been supported since ext-monogdb
1.2.0. Is there any reason that wasn't done in the original implementation?
It's almost 2018 and I'm very willing to close this and ignore 32-bit platforms (sorry @jwage).
Yeah, gonna do that now it's 2023 👼
@jwage mentioned that https://github.com/doctrine/mongodb-odm/commit/c36c0606fb0a2f933e843cf68963f3cf4e8f207f failed for him on a 32-bit test environment:
This is due to the the test date exceeding the bounds for a negative 32-bit int. From
strtotime()
's documentation:Interestingly, DateTime doesn't seem to have this problem:
This is mainly because it prints a
long long
directly to a string buffer (see: here), which it returns. Meanwhile,strtotime()
returns a platform-dependentlong
(see: here).There is no clear solution for ODM, since
MongoDate::__construct()
takeslong
values for itssec
andusec
parameters. Ultimately, MongoDate would need to accept a string as its first argument, and parse that directly into anint64_t
(reported and tracked by PHP-1424).