Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-790

UTCDateTime constructor should truncate floats

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.2.0
    • Affects Version/s: 1.2.0-alpha2
    • Component/s: None
    • Labels:
      None

      PHPC-726 changed the Timestamp and UTCDateTime initialization methods to convert strings to integers and raise exceptions on failure. This process is more strict that PHP's own string-to-integer conversion, as the following fails:

      new MongoDB\BSON\UTCDatetime(microtime(true) * 1000);

      MongoDB\Driver\Exception\InvalidArgumentException with message 'Error parsing "1473959591217.2" as 64-bit integer for MongoDB\BSON\UTCDateTime initialization'

      We should address this before it affects many users that were constructing UTCDateTime for the current time using microtime(), which was necessary before we started defaulting to the current time in 1.2.0-alpha1 (PHPC-536).

      Note: There is no practical reason to support truncation of floats for Timestamp arguments.

            Assignee:
            jmikola@mongodb.com Jeremy Mikola
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: