@@ -216,12 +216,49 @@ static HashTable* phongo_readconcern_get_properties(zend_object* object)
216216 return phongo_readconcern_get_properties_hash (object , false);
217217}
218218
219+ static int phongo_readconcern_compare_objects (zval * o1 , zval * o2 )
220+ {
221+ ZEND_COMPARE_OBJECTS_FALLBACK (o1 , o2 );
222+
223+ phongo_readconcern_t * intern1 ;
224+ phongo_readconcern_t * intern2 ;
225+
226+ const char * level1 = NULL ;
227+ const char * level2 = NULL ;
228+
229+ intern1 = Z_READCONCERN_OBJ_P (o1 );
230+ intern2 = Z_READCONCERN_OBJ_P (o2 );
231+
232+ if (intern1 && intern1 -> read_concern ) {
233+ level1 = mongoc_read_concern_get_level (intern1 -> read_concern );
234+ }
235+
236+ if (intern2 && intern2 -> read_concern ) {
237+ level2 = mongoc_read_concern_get_level (intern2 -> read_concern );
238+ }
239+
240+ if (level1 == NULL && level2 == NULL ) {
241+ return 0 ;
242+ }
243+
244+ if (level1 == NULL ) {
245+ return -1 ;
246+ }
247+
248+ if (level2 == NULL ) {
249+ return 1 ;
250+ }
251+
252+ return strcmp (level1 , level2 );
253+ }
254+
219255void phongo_readconcern_init_ce (INIT_FUNC_ARGS )
220256{
221257 phongo_readconcern_ce = register_class_MongoDB_Driver_ReadConcern (phongo_serializable_ce );
222258 phongo_readconcern_ce -> create_object = phongo_readconcern_create_object ;
223259
224260 memcpy (& phongo_handler_readconcern , phongo_get_std_object_handlers (), sizeof (zend_object_handlers ));
261+ phongo_handler_readconcern .compare = phongo_readconcern_compare_objects ;
225262 phongo_handler_readconcern .get_debug_info = phongo_readconcern_get_debug_info ;
226263 phongo_handler_readconcern .get_properties = phongo_readconcern_get_properties ;
227264 phongo_handler_readconcern .free_obj = phongo_readconcern_free_object ;
0 commit comments