2929zend_class_entry * php_phongo_serverdescription_ce ;
3030
3131/* {{{ proto array MongoDB\Driver\ServerDescription::getHelloResponse()
32- Returns the most recent " hello" response */
32+ Returns the most recent " hello" response */
3333static PHP_METHOD (ServerDescription , getHelloResponse )
3434{
3535 php_phongo_serverdescription_t * intern ;
3636 const bson_t * helloResponse ;
37+ php_phongo_bson_state state ;
3738
3839 intern = Z_SERVERDESCRIPTION_OBJ_P (getThis ());
3940
4041 PHONGO_PARSE_PARAMETERS_NONE ();
4142
4243 helloResponse = mongoc_server_description_hello_response (intern -> server_description );
4344
44- if (helloResponse -> len ) {
45- php_phongo_bson_state state ;
46- 47- PHONGO_BSON_INIT_DEBUG_STATE (state );
48- 49- if (!php_phongo_bson_to_zval_ex (bson_get_data (helloResponse ), helloResponse -> len , & state )) {
50- zval_ptr_dtor (& state .zchild );
51- return ;
52- }
45+ PHONGO_BSON_INIT_DEBUG_STATE (state );
5346
54- RETURN_ZVAL (& state .zchild , 0 , 1 );
55- } else {
56- RETURN_NULL ();
47+ if (!php_phongo_bson_to_zval_ex (bson_get_data (helloResponse ), helloResponse -> len , & state )) {
48+ /* Exception should already have been thrown */
49+ zval_ptr_dtor (& state .zchild );
50+ return ;
5751 }
52+ 53+ RETURN_ZVAL (& state .zchild , 0 , 1 );
5854} /* }}} */
5955
6056/* {{{ proto string MongoDB\Driver\ServerDescription::getHost()
61- Returns the server’ s hostname */
57+ Returns the server' s hostname */
6258static PHP_METHOD (ServerDescription , getHost )
6359{
6460 php_phongo_serverdescription_t * intern ;
@@ -80,7 +76,7 @@ static PHP_METHOD(ServerDescription, getLastUpdateTime)
8076
8177 PHONGO_PARSE_PARAMETERS_NONE ();
8278
83- RETVAL_LONG (( zend_long ) mongoc_server_description_last_update_time (intern -> server_description ));
79+ RETVAL_LONG (mongoc_server_description_last_update_time (intern -> server_description ));
8480} /* }}} */
8581
8682/* {{{ proto integer MongoDB\Driver\ServerDescription::getPort()
@@ -106,7 +102,7 @@ static PHP_METHOD(ServerDescription, getRoundTripTime)
106102
107103 PHONGO_PARSE_PARAMETERS_NONE ();
108104
109- RETVAL_LONG (( zend_long ) mongoc_server_description_round_trip_time (intern -> server_description ));
105+ RETVAL_LONG (mongoc_server_description_round_trip_time (intern -> server_description ));
110106} /* }}} */
111107
112108/* {{{ proto integer MongoDB\Driver\ServerDescription::getType()
@@ -180,7 +176,7 @@ HashTable* php_phongo_serverdescription_get_properties_hash(phongo_compat_object
180176
181177 intern = Z_OBJ_SERVERDESCRIPTION (PHONGO_COMPAT_GET_OBJ (object ));
182178
183- PHONGO_GET_PROPERTY_HASH_INIT_PROPS (is_debug , intern , props , 2 );
179+ PHONGO_GET_PROPERTY_HASH_INIT_PROPS (is_debug , intern , props , 6 );
184180
185181 {
186182 zval host , port , type ;
@@ -203,20 +199,22 @@ HashTable* php_phongo_serverdescription_get_properties_hash(phongo_compat_object
203199 PHONGO_BSON_INIT_DEBUG_STATE (state );
204200
205201 if (!php_phongo_bson_to_zval_ex (bson_get_data (hello_response ), hello_response -> len , & state )) {
206- return false;
202+ zval_ptr_dtor (& state .zchild );
203+ goto done ;
207204 }
208205 zend_hash_str_update (props , "hello_response" , sizeof ("hello_response" ) - 1 , & state .zchild );
209206 }
210207
211208 {
212209 zval last_update_time , round_trip_time ;
213210
214- ZVAL_LONG (& last_update_time , ( zend_long ) mongoc_server_description_last_update_time (intern -> server_description ));
211+ ZVAL_LONG (& last_update_time , mongoc_server_description_last_update_time (intern -> server_description ));
215212 zend_hash_str_update (props , "last_update_time" , sizeof ("last_update_time" ) - 1 , & last_update_time );
216- ZVAL_LONG (& round_trip_time , ( zend_long ) mongoc_server_description_round_trip_time (intern -> server_description ));
213+ ZVAL_LONG (& round_trip_time , mongoc_server_description_round_trip_time (intern -> server_description ));
217214 zend_hash_str_update (props , "round_trip_time" , sizeof ("round_trip_time" ) - 1 , & round_trip_time );
218215 }
219216
217+ done :
220218 return props ;
221219} /* }}} */
222220
0 commit comments