Skip to content

Commit f9fe7ef

Browse files
authored
PHPC-1985: Report unset round_trip_time as null in Server debug output (#1265)
1 parent e37063d commit f9fe7ef

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

php_phongo.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,12 @@ bool php_phongo_server_to_zval(zval* retval, mongoc_client_t* client, mongoc_ser
12231223
ADD_ASSOC_ZVAL_EX(retval, "last_hello_response", &state.zchild);
12241224
}
12251225

1226-
ADD_ASSOC_LONG_EX(retval, "round_trip_time", (zend_long) mongoc_server_description_round_trip_time(sd));
1226+
/* TODO: Use MONGOC_RTT_UNSET once it is added to libmongoc's public API (CDRIVER-4176) */
1227+
if (mongoc_server_description_round_trip_time(sd) == -1) {
1228+
ADD_ASSOC_NULL_EX(retval, "round_trip_time");
1229+
} else {
1230+
ADD_ASSOC_LONG_EX(retval, "round_trip_time", (zend_long) mongoc_server_description_round_trip_time(sd));
1231+
}
12271232

12281233
return true;
12291234
} /* }}} */

tests/server/server-debug.phpt

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ object(MongoDB\Driver\Server)#%d (%d) {
3838
%a
3939
}
4040
["round_trip_time"]=>
41-
int(%i)
41+
%r(NULL|int\(\d+\))%r
4242
}
4343
===DONE===

0 commit comments

Comments
 (0)