@@ -97,17 +97,49 @@ static PHP_METHOD(ReadConcern, isDefault)
9797 RETURN_BOOL (mongoc_read_concern_is_default (intern -> read_concern ));
9898} /* }}} */
9999
100+ static HashTable * php_phongo_read_concern_get_properties_hash (zval * object , bool is_debug TSRMLS_DC ) /* {{{ */
101+ {
102+ php_phongo_readconcern_t * intern ;
103+ HashTable * props ;
104+ const char * level ;
105+
106+ intern = Z_READCONCERN_OBJ_P (object );
107+
108+ PHONGO_GET_PROPERTY_HASH_INIT_PROPS (is_debug , intern , props , 1 );
109+
110+ if (!intern -> read_concern ) {
111+ return props ;
112+ }
113+
114+ level = mongoc_read_concern_get_level (intern -> read_concern );
115+
116+ if (level ) {
117+ #if PHP_VERSION_ID >= 70000
118+ zval z_level ;
119+
120+ ZVAL_STRING (& z_level , level );
121+ zend_hash_str_update (props , "level" , sizeof ("level" ) - 1 , & z_level );
122+ #else
123+ zval * z_level ;
124+
125+ MAKE_STD_ZVAL (z_level );
126+ ZVAL_STRING (z_level , level , 1 );
127+ zend_hash_update (props , "level" , sizeof ("level" ), & z_level , sizeof (z_level ), NULL );
128+ #endif
129+ }
130+
131+ return props ;
132+ } /* }}} */
133+
100134/* {{{ proto array MongoDB\Driver\ReadConcern::bsonSerialize()
101135*/
102136static PHP_METHOD (ReadConcern , bsonSerialize )
103137{
104- const mongoc_read_concern_t * read_concern = phongo_read_concern_from_zval (getThis () TSRMLS_CC );
105-
106138 if (zend_parse_parameters_none () == FAILURE ) {
107139 return ;
108140 }
109141
110- php_phongo_read_concern_to_zval (return_value , read_concern );
142+ ZVAL_ARR (return_value , php_phongo_read_concern_get_properties_hash ( getThis (), true TSRMLS_CC ) );
111143 convert_to_object (return_value );
112144} /* }}} */
113145
@@ -139,6 +171,11 @@ static void php_phongo_readconcern_free_object(phongo_free_object_arg* object TS
139171
140172 zend_object_std_dtor (& intern -> std TSRMLS_CC );
141173
174+ if (intern -> properties ) {
175+ zend_hash_destroy (intern -> properties );
176+ FREE_HASHTABLE (intern -> properties );
177+ }
178+
142179 if (intern -> read_concern ) {
143180 mongoc_read_concern_destroy (intern -> read_concern );
144181 }
@@ -174,15 +211,14 @@ static phongo_create_object_retval php_phongo_readconcern_create_object(zend_cla
174211
175212static HashTable * php_phongo_readconcern_get_debug_info (zval * object , int * is_temp TSRMLS_DC ) /* {{{ */
176213{
177- zval retval = ZVAL_STATIC_INIT ;
178- const mongoc_read_concern_t * read_concern = phongo_read_concern_from_zval (object TSRMLS_CC );
179-
180214 * is_temp = 1 ;
181- php_phongo_read_concern_to_zval (& retval , read_concern );
215+ return php_phongo_read_concern_get_properties_hash (object , true TSRMLS_CC );
216+ } /* }}} */
182217
183- return Z_ARRVAL (retval );
218+ static HashTable * php_phongo_readconcern_get_properties (zval * object TSRMLS_DC ) /* {{{ */
219+ {
220+ return php_phongo_read_concern_get_properties_hash (object , false TSRMLS_CC );
184221} /* }}} */
185- /* }}} */
186222
187223void php_phongo_readconcern_init_ce (INIT_FUNC_ARGS ) /* {{{ */
188224{
@@ -198,6 +234,7 @@ void php_phongo_readconcern_init_ce(INIT_FUNC_ARGS) /* {{{ */
198234
199235 memcpy (& php_phongo_handler_readconcern , phongo_get_std_object_handlers (), sizeof (zend_object_handlers ));
200236 php_phongo_handler_readconcern .get_debug_info = php_phongo_readconcern_get_debug_info ;
237+ php_phongo_handler_readconcern .get_properties = php_phongo_readconcern_get_properties ;
201238#if PHP_VERSION_ID >= 70000
202239 php_phongo_handler_readconcern .free_obj = php_phongo_readconcern_free_object ;
203240 php_phongo_handler_readconcern .offset = XtOffsetOf (php_phongo_readconcern_t , std );
0 commit comments