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

BulkWrite::update() silently ignores invalid arguments

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 1.2.0-alpha3, 1.2.0
    • Affects Version/s: 1.1.8
    • Component/s: None
    • None

      The following parameters are rejected by libmongoc and no write is added to the bulk object; however, a debug log message is the only indication of failure.

      Update document contains dotted keys but no dollar keys

      <?php
      
      ini_set('mongodb.debug', 'stderr');
      
      $b = new MongoDB\Driver\BulkWrite;
      $b->update(['x'=>1], ['y.x'=>1]);
      var_dump(count($b));
      
      [2016-09-20T23:52:19+00:00]     mongoc: TRACE   > ENTRY: mongoc_bulk_operation_replace_one():246
      [2016-09-20T23:52:19+00:00]     mongoc: WARNING > mongoc_bulk_operation_replace_one(): replacement document may not contain $ or . in keys. Ignoring document.
      [2016-09-20T23:52:19+00:00]     mongoc: TRACE   >  EXIT: mongoc_bulk_operation_replace_one():252
      int(0)
      

      Replacement document with multi=true

      <?php
      
      ini_set('mongodb.debug', 'stderr');
      
      $b = new MongoDB\Driver\BulkWrite;
      $b->update(['x'=>1], ['y'=>1], ['multi' => true]);
      var_dump(count($b));
      
      [2016-09-20T23:59:04+00:00]     mongoc: TRACE   > ENTRY: mongoc_bulk_operation_update():288
      [2016-09-20T23:59:04+00:00]     mongoc: WARNING > mongoc_bulk_operation_update(): update only works with $ operators.
      [2016-09-20T23:59:04+00:00]     mongoc: TRACE   >  EXIT: mongoc_bulk_operation_update():295
      int(0)
      

            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: