Skip to content

Commit 08ba376

Browse files
committed
Explicitly handle serialize output in php_phongo_writeconcern_get_properties_hash
1 parent aff6c8c commit 08ba376

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/MongoDB/WriteConcern.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ static PHP_METHOD(WriteConcern, isDefault)
298298
RETURN_BOOL(mongoc_write_concern_is_default(intern->write_concern));
299299
} /* }}} */
300300

301-
static HashTable* php_phongo_writeconcern_get_properties_hash(phongo_compat_object_handler_type* object, bool is_temp, bool is_bson) /* {{{ */
301+
static HashTable* php_phongo_writeconcern_get_properties_hash(phongo_compat_object_handler_type* object, bool is_temp, bool is_bson, bool is_serialize) /* {{{ */
302302
{
303303
php_phongo_writeconcern_t* intern;
304304
HashTable* props;
@@ -344,6 +344,12 @@ static HashTable* php_phongo_writeconcern_get_properties_hash(phongo_compat_obje
344344

345345
if (is_bson) {
346346
ZVAL_INT64(&z_wtimeout, wtimeout);
347+
} else if (is_serialize) {
348+
if (wtimeout > INT32_MAX || wtimeout < INT32_MIN) {
349+
ZVAL_INT64_STRING(&z_wtimeout, wtimeout);
350+
} else {
351+
ZVAL_LONG(&z_wtimeout, wtimeout);
352+
}
347353
} else {
348354
#if SIZEOF_ZEND_LONG == 4
349355
if (wtimeout > INT32_MAX || wtimeout < INT32_MIN) {
@@ -376,7 +382,7 @@ static PHP_METHOD(WriteConcern, bsonSerialize)
376382
}
377383
zend_restore_error_handling(&error_handling);
378384

379-
ZVAL_ARR(return_value, php_phongo_writeconcern_get_properties_hash(PHONGO_COMPAT_OBJ_P(getThis()), true, true));
385+
ZVAL_ARR(return_value, php_phongo_writeconcern_get_properties_hash(PHONGO_COMPAT_OBJ_P(getThis()), true, true, false));
380386
convert_to_object(return_value);
381387
} /* }}} */
382388

@@ -487,7 +493,7 @@ static PHP_METHOD(WriteConcern, __serialize)
487493
{
488494
PHONGO_PARSE_PARAMETERS_NONE();
489495

490-
RETURN_ARR(php_phongo_writeconcern_get_properties_hash(PHONGO_COMPAT_OBJ_P(getThis()), true, false));
496+
RETURN_ARR(php_phongo_writeconcern_get_properties_hash(PHONGO_COMPAT_OBJ_P(getThis()), true, false, true));
491497
} /* }}} */
492498

493499
/* {{{ proto array MongoDB\Driver\WriteConcern::__unserialize()
@@ -579,12 +585,12 @@ static zend_object* php_phongo_writeconcern_create_object(zend_class_entry* clas
579585
static HashTable* php_phongo_writeconcern_get_debug_info(phongo_compat_object_handler_type* object, int* is_temp) /* {{{ */
580586
{
581587
*is_temp = 1;
582-
return php_phongo_writeconcern_get_properties_hash(object, true, false);
588+
return php_phongo_writeconcern_get_properties_hash(object, true, false, false);
583589
} /* }}} */
584590

585591
static HashTable* php_phongo_writeconcern_get_properties(phongo_compat_object_handler_type* object) /* {{{ */
586592
{
587-
return php_phongo_writeconcern_get_properties_hash(object, false, false);
593+
return php_phongo_writeconcern_get_properties_hash(object, false, false, false);
588594
} /* }}} */
589595

590596
void php_phongo_writeconcern_init_ce(INIT_FUNC_ARGS) /* {{{ */

0 commit comments

Comments
 (0)