Uploaded image for project: 'PHP Legacy Driver'
  1. PHP Legacy Driver
  2. PHP-138

64-bit int gets truncated by PHP-MongoDB driver

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.10
    • Component/s: pecl-mongo
    • Labels:
      None
    • Environment:
      64-bit Ubuntu PHP 5.3.2 (originally reported to me from one of my team-members having this issue on OSX)
    • # Replies:
      9
    • Last comment by Customer:
      true

      Description

      echo PHP_INT_MAX;
      // 9223372036854775807
      // confirms a 64-bit environment

      $id = array('_id' => 100000154115727);

      echo $id['_id'];
      // 100000154115727
      echo gettype($id['_id']);
      // int

      $mongo->test->insert($id);
      $id = $mongo->test->findOne();

      echo $id['_id'];
      // 430562959
      echo gettype($id['_id']);
      // int

      From the Mongo CLI everything works correctly and confirms that the 64-bit int is indeed truncated within Mongo:

      > db.test.findOne()

      { "_id" : 430562959 }

      > db.test.save(

      { "_id" : 100000154115727 }

      )

      > db.test.find()

      { "_id" : 430562959 } { "_id" : 100000154115727 }

      > db.test.find(

      { "_id" : 430562959 }

      )

      { "_id" : 430562959 }

      > db.test.find(

      { "_id" : 100000154115727 }

      )

      { "_id" : 100000154115727 }

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                3 years, 48 weeks, 6 days ago
                Date of 1st Reply: