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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • 1.2.6
    • Affects Version/s: 1.2.2
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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:
            Jeremy Mikola
            Reporter:
            Jeremy Mikola
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: