Uploaded image for project: 'PHP Driver: Library'
  1. PHP Driver: Library
  2. PHPLIB-152

Do not specify negative limit in FindOne operation

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.0.0-beta2
    • Affects Version/s: 1.0.0-beta1
    • Component/s: None
    • None

      With the 1.3.0 upgrade, the findOne test within PHPLIB began triggering this assertion failure in libmongoc:

      src/libmongoc/src/mongoc/mongoc-cursor.c:52 _mongoc_n_return(): precondition failed: remaining > 0

      Dumping the Query object in the PHP driver reported int(4294967295) as the limit (largest possible 32-bit int), which jives with libmongoc using a uint32_t for the cursor limit and PHPLIB specifying -1 for its FindOne limit. IIRC, -1 and 1 are both handled the same by the server (the cursor is immediately closed), so it's a trivial fix in PHPLIB to use 1 instead of -1.

            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: