-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: 1.19.4
-
Component/s: None
-
None
-
PHP Drivers
-
Not Needed
-
The compare handler for MongoDB\BSON\Int64 uses ZEND_COMPARE_OBJECTS_FALLBACK, which can be used to limit comparisons to objects of the same type. While this works for most of our classes, Int64 is special as we want to default to loose type comparisons. For example, new Int64(0) == 0 should always evaluate to true. This is currently true as the comparison handler resorts to casting the Int64 instance to the desired type, int in this case.
This has the side effect of triggering a warning when comparing an Int64 instance with a value outside of the 32-bit range with an int on a 32-bit platform, as we're truncating the value during the cast. This should not be necessary, as we can internally work with 64-bit values and return the correct value without triggering a truncation warning.