Skip to content

Commit fe60b8b

Browse files
committed
Check for _id extraction before appending insert
1 parent f5e7238 commit fe60b8b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/MongoDB/BulkWriteCommand.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -437,18 +437,18 @@ static PHP_METHOD(MongoDB_Driver_BulkWriteCommand, insertOne)
437437
goto cleanup;
438438
}
439439

440+
if (!bson_out) {
441+
phongo_throw_exception(PHONGO_ERROR_LOGIC, "php_phongo_zval_to_bson() did not return an _id. Please file a bug report.");
442+
goto cleanup;
443+
}
444+
440445
if (!mongoc_bulkwrite_append_insertone(intern->bw, ns, &bdocument, NULL, &error)) {
441446
phongo_throw_exception_from_bson_error_t(&error);
442447
goto cleanup;
443448
}
444449

445450
intern->num_ops++;
446451

447-
if (!bson_out) {
448-
phongo_throw_exception(PHONGO_ERROR_LOGIC, "php_phongo_zval_to_bson() did not return document identifier. Please file a bug report.");
449-
goto cleanup;
450-
}
451-
452452
phongo_bwc_extract_id(bson_out, &return_value);
453453

454454
cleanup:

0 commit comments

Comments
 (0)