@@ -1546,6 +1546,33 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
1546
1546
{
1547
1547
zend_object * zobj1 , * zobj2 ;
1548
1548
1549
+ if (Z_TYPE_P (o1 ) != Z_TYPE_P (o2 )) {
1550
+ /* Object and non-object */
1551
+ zval casted ;
1552
+ if (Z_TYPE_P (o1 ) == IS_OBJECT ) {
1553
+ ZEND_ASSERT (Z_TYPE_P (o2 ) != IS_OBJECT );
1554
+ if (Z_OBJ_HT_P (o1 )-> cast_object ) {
1555
+ if (Z_OBJ_HT_P (o1 )-> cast_object (Z_OBJ_P (o1 ), & casted , ((Z_TYPE_P (o2 ) == IS_FALSE || Z_TYPE_P (o2 ) == IS_TRUE ) ? _IS_BOOL : Z_TYPE_P (o2 ))) == FAILURE ) {
1556
+ return 1 ;
1557
+ }
1558
+ int ret = zend_compare (& casted , o2 );
1559
+ zval_ptr_dtor (& casted );
1560
+ return ret ;
1561
+ }
1562
+ } else {
1563
+ ZEND_ASSERT (Z_TYPE_P (o2 ) == IS_OBJECT );
1564
+ if (Z_OBJ_HT_P (o2 )-> cast_object ) {
1565
+ if (Z_OBJ_HT_P (o2 )-> cast_object (Z_OBJ_P (o2 ), & casted , ((Z_TYPE_P (o1 ) == IS_FALSE || Z_TYPE_P (o1 ) == IS_TRUE ) ? _IS_BOOL : Z_TYPE_P (o1 ))) == FAILURE ) {
1566
+ return -1 ;
1567
+ }
1568
+ int ret = zend_compare (o1 , & casted );
1569
+ zval_ptr_dtor (& casted );
1570
+ return ret ;
1571
+ }
1572
+ }
1573
+ return 1 ;
1574
+ }
1575
+
1549
1576
zobj1 = Z_OBJ_P (o1 );
1550
1577
zobj2 = Z_OBJ_P (o2 );
1551
1578
@@ -1582,15 +1609,12 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
1582
1609
1583
1610
if (Z_TYPE_P (p1 ) != IS_UNDEF ) {
1584
1611
if (Z_TYPE_P (p2 ) != IS_UNDEF ) {
1585
- zval result ;
1612
+ int ret ;
1586
1613
1587
- if (compare_function (& result , p1 , p2 )== FAILURE ) {
1588
- Z_UNPROTECT_RECURSION_P (o1 );
1589
- return 1 ;
1590
- }
1591
- if (Z_LVAL (result ) != 0 ) {
1614
+ ret = zend_compare (p1 , p2 );
1615
+ if (ret != 0 ) {
1592
1616
Z_UNPROTECT_RECURSION_P (o1 );
1593
- return Z_LVAL ( result ) ;
1617
+ return ret ;
1594
1618
}
1595
1619
} else {
1596
1620
Z_UNPROTECT_RECURSION_P (o1 );
@@ -1850,13 +1874,12 @@ ZEND_API const zend_object_handlers std_object_handlers = {
1850
1874
zend_std_get_method , /* get_method */
1851
1875
zend_std_get_constructor , /* get_constructor */
1852
1876
zend_std_get_class_name , /* get_class_name */
1853
- zend_std_compare_objects , /* compare_objects */
1854
1877
zend_std_cast_object_tostring , /* cast_object */
1855
1878
NULL , /* count_elements */
1856
1879
zend_std_get_debug_info , /* get_debug_info */
1857
1880
zend_std_get_closure , /* get_closure */
1858
1881
zend_std_get_gc , /* get_gc */
1859
1882
NULL , /* do_operation */
1860
- NULL , /* compare */
1883
+ zend_std_compare_objects , /* compare */
1861
1884
NULL , /* get_properties_for */
1862
1885
};
0 commit comments