Skip to content

Commit e52355e

Browse files
committed
Fix comparison logic on PHP 7.4
1 parent c296398 commit e52355e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/BSON/Int64.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,15 @@ static int php_phongo_int64_compare_objects(zval* o1, zval* o2)
345345
return 0;
346346
}
347347

348+
#if PHP_VERSION_ID < 80000
349+
static int php_phongo_int64_compare_zvals(zval* result, zval* op1, zval* op2)
350+
{
351+
ZVAL_LONG(result, php_phongo_int64_compare_objects(op1, op2));
352+
353+
return SUCCESS;
354+
}
355+
#endif
356+
348357
static zend_result php_phongo_int64_cast_object(phongo_compat_object_handler_type* readobj, zval* retval, int type)
349358
{
350359
php_phongo_int64_t* intern;
@@ -627,6 +636,12 @@ void php_phongo_int64_init_ce(INIT_FUNC_ARGS)
627636
php_phongo_handler_int64.offset = XtOffsetOf(php_phongo_int64_t, std);
628637
php_phongo_handler_int64.cast_object = php_phongo_int64_cast_object;
629638
php_phongo_handler_int64.do_operation = php_phongo_int64_do_operation;
639+
640+
/* On PHP 7.4, compare_objects is only used when comparing two objects.
641+
* Use the compare handler to compare an object with any other zval */
642+
#if PHP_VERSION_ID < 80000
643+
php_phongo_handler_int64.compare = php_phongo_int64_compare_zvals;
644+
#endif
630645
}
631646

632647
bool phongo_int64_new(zval* object, int64_t integer)

0 commit comments

Comments
 (0)