Skip to content

Commit 09c56d6

Browse files
authored
Remove phongo_write_concern_to_zval (#1983)
2 parents fb575fd + 435e656 commit 09c56d6

4 files changed

Lines changed: 4 additions & 37 deletions

File tree

src/MongoDB/BulkWrite.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ static HashTable* phongo_bulkwrite_get_debug_info(zend_object* object, int* is_t
642642
if (mongoc_bulk_operation_get_write_concern(intern->bulk)) {
643643
zval write_concern;
644644

645-
phongo_write_concern_to_zval(&write_concern, mongoc_bulk_operation_get_write_concern(intern->bulk));
645+
phongo_writeconcern_init(&write_concern, mongoc_bulk_operation_get_write_concern(intern->bulk));
646646
ADD_ASSOC_ZVAL_EX(&retval, "write_concern", &write_concern);
647647
} else {
648648
ADD_ASSOC_NULL_EX(&retval, "write_concern");

src/MongoDB/WriteConcern.c

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -388,36 +388,3 @@ const mongoc_write_concern_t* phongo_write_concern_from_zval(zval* zwrite_concer
388388

389389
return NULL;
390390
}
391-
392-
void phongo_write_concern_to_zval(zval* retval, const mongoc_write_concern_t* write_concern)
393-
{
394-
const char* wtag = mongoc_write_concern_get_wtag(write_concern);
395-
const int32_t w = mongoc_write_concern_get_w(write_concern);
396-
const int64_t wtimeout = mongoc_write_concern_get_wtimeout_int64(write_concern);
397-
398-
array_init_size(retval, 4);
399-
400-
if (wtag) {
401-
ADD_ASSOC_STRING(retval, "w", wtag);
402-
} else if (mongoc_write_concern_get_wmajority(write_concern)) {
403-
ADD_ASSOC_STRING(retval, "w", PHONGO_WRITE_CONCERN_W_MAJORITY);
404-
} else if (w != MONGOC_WRITE_CONCERN_W_DEFAULT) {
405-
ADD_ASSOC_LONG_EX(retval, "w", w);
406-
}
407-
408-
if (mongoc_write_concern_journal_is_set(write_concern)) {
409-
ADD_ASSOC_BOOL_EX(retval, "j", mongoc_write_concern_get_journal(write_concern));
410-
}
411-
412-
if (wtimeout != 0) {
413-
#if SIZEOF_ZEND_LONG == 4
414-
if (wtimeout > INT32_MAX || wtimeout < INT32_MIN) {
415-
ADD_ASSOC_INT64_AS_STRING(retval, "wtimeout", wtimeout);
416-
} else {
417-
ADD_ASSOC_LONG_EX(retval, "wtimeout", wtimeout);
418-
}
419-
#else
420-
ADD_ASSOC_LONG_EX(retval, "wtimeout", wtimeout);
421-
#endif
422-
}
423-
}

src/MongoDB/WriteConcern.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,4 @@ void phongo_writeconcern_init(zval* return_value, const mongoc_write_concern_t*
2727

2828
const mongoc_write_concern_t* phongo_write_concern_from_zval(zval* zwrite_concern);
2929

30-
void phongo_write_concern_to_zval(zval* retval, const mongoc_write_concern_t* write_concern);
31-
3230
#endif /* PHONGO_WRITECONCERN_H */

tests/bulk/write-0002.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ object(MongoDB\Driver\BulkWrite)#%d (%d) {
7070
["session"]=>
7171
NULL
7272
["write_concern"]=>
73-
array(%d) {
73+
object(MongoDB\Driver\WriteConcern)#%d (%d) {
7474
["w"]=>
7575
int(1)
76+
["j"]=>
77+
NULL
7678
["wtimeout"]=>
7779
int(1000)
7880
}

0 commit comments

Comments
 (0)