@@ -401,7 +401,7 @@ void php_phongo_bulkwritecommandresult_init_ce(INIT_FUNC_ARGS)
401
401
402
402
static inline bson_t * _bson_copy_or_null (const bson_t * bson )
403
403
{
404
- return bson_empty0 ( bson ) ? NULL : bson_copy (bson );
404
+ return bson ? bson_copy (bson ) : NULL ;
405
405
}
406
406
407
407
php_phongo_bulkwritecommandresult_t * phongo_bulkwritecommandresult_init (zval * return_value , mongoc_bulkwritereturn_t * bw_ret , zval * manager )
@@ -421,16 +421,18 @@ php_phongo_bulkwritecommandresult_t* phongo_bulkwritecommandresult_init(zval* re
421
421
bwcr -> modified_count = mongoc_bulkwriteresult_modifiedcount (bw_ret -> res );
422
422
bwcr -> deleted_count = mongoc_bulkwriteresult_deletedcount (bw_ret -> res );
423
423
424
+ // Result documents will null if verboseResults=false
424
425
bwcr -> insert_results = _bson_copy_or_null (mongoc_bulkwriteresult_insertresults (bw_ret -> res ));
425
426
bwcr -> update_results = _bson_copy_or_null (mongoc_bulkwriteresult_updateresults (bw_ret -> res ));
426
427
bwcr -> delete_results = _bson_copy_or_null (mongoc_bulkwriteresult_deleteresults (bw_ret -> res ));
427
428
}
428
429
429
- // Copy mongoc_bulkwriteexception_t fields
430
+ /* If any error(s) occurred, mongoc_bulkwriteexception_t will be non-null.
431
+ * Copy its fields into the result object. */
430
432
if (bw_ret -> exc ) {
431
- bwcr -> error_reply = _bson_copy_or_null (mongoc_bulkwriteexception_errorreply (bw_ret -> exc ));
432
- bwcr -> write_errors = _bson_copy_or_null (mongoc_bulkwriteexception_writeerrors (bw_ret -> exc ));
433
- bwcr -> write_concern_errors = _bson_copy_or_null (mongoc_bulkwriteexception_writeconcernerrors (bw_ret -> exc ));
433
+ bwcr -> error_reply = bson_copy (mongoc_bulkwriteexception_errorreply (bw_ret -> exc ));
434
+ bwcr -> write_errors = bson_copy (mongoc_bulkwriteexception_writeerrors (bw_ret -> exc ));
435
+ bwcr -> write_concern_errors = bson_copy (mongoc_bulkwriteexception_writeconcernerrors (bw_ret -> exc ));
434
436
}
435
437
436
438
ZVAL_ZVAL (& bwcr -> manager , manager , 1 , 0 );
0 commit comments