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

Cursor::setTypeMap() may unnecessarily convert first BSON document

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.2.6
    • Affects Version/s: 1.2.2
    • Component/s: None
    • Labels:
      None

      The fix for PHPC-849 always applies the new type map to the cursor's current element by calling phongo_bson_to_zval_ex() if a current element exists. Since phongo_advance_cursor_and_check_for_error() advances to the cursor's first element to check for an error before MongoDB\Driver\Cursor is even initialized, any cursor with at least one document in its result set will always have a current element (even before iteration begins). Since the PHP library is prone to calling setTypeMap() on most cursors it creates, this can lead to redundant BSON conversion as described in this mongodb-user post.

            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: