1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
This fixes the issue just for the Socket class. Presumably we'll
want to do the same for other "resource" objects.
This commit is contained in:
Nikita Popov
2021-02-16 12:32:43 +01:00
parent 2dc75a9e93
commit cb9785add1
5 changed files with 35 additions and 0 deletions

4
NEWS
View File

@@ -35,6 +35,10 @@ PHP NEWS
. Fixed bug #70091 (Phar does not mark UTF-8 filenames in ZIP archives). (cmb)
. Fixed bug #53467 (Phar cannot compress large archives). (cmb, lserni)
- Socket:
. Fixed bug #80723 (Different sockets compare as equal (regression in 8.0)).
(Nikita)
- SPL:
. Fixed bug#80719 (Iterating after failed ArrayObject::setIteratorClass()
causes Segmentation fault). (Nikita)

View File

@@ -1608,6 +1608,11 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2) /* {{{ */
}
/* }}} */
ZEND_API int zend_objects_not_comparable(zval *o1, zval *o2)
{
return ZEND_UNCOMPARABLE;
}
ZEND_API int zend_std_has_property(zend_object *zobj, zend_string *name, int has_set_exists, void **cache_slot) /* {{{ */
{
int result;

View File

@@ -213,6 +213,10 @@ ZEND_API int zend_std_compare_objects(zval *o1, zval *o2);
ZEND_API int zend_std_get_closure(zend_object *obj, zend_class_entry **ce_ptr, zend_function **fptr_ptr, zend_object **obj_ptr, zend_bool check_only);
ZEND_API void rebuild_object_properties(zend_object *zobj);
/* Handler for objects that cannot be meaningfully compared.
* Only objects with the same identity will be considered equal. */
ZEND_API int zend_objects_not_comparable(zval *o1, zval *o2);
ZEND_API int zend_check_protected(zend_class_entry *ce, zend_class_entry *scope);
ZEND_API int zend_check_property_access(zend_object *zobj, zend_string *prop_info_name, zend_bool is_dynamic);

View File

@@ -446,6 +446,7 @@ static PHP_MINIT_FUNCTION(sockets)
socket_object_handlers.get_constructor = socket_get_constructor;
socket_object_handlers.clone_obj = NULL;
socket_object_handlers.get_gc = socket_get_gc;
socket_object_handlers.compare = zend_objects_not_comparable;
zend_class_entry ce_address_info;
INIT_CLASS_ENTRY(ce_address_info, "AddressInfo", class_AddressInfo_methods);

View File

@@ -0,0 +1,21 @@
--TEST--
Bug #80723: Different sockets compare as equal (regression in 8.0)
--FILE--
<?php
$socket_1 = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$socket_2 = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
var_dump($socket_1 == $socket_1);
var_dump($socket_2 == $socket_2);
var_dump($socket_1 == $socket_2);
$vector = array(1 => $socket_1, 2 => $socket_2);
var_dump(array_search($socket_1, $vector));
var_dump(array_search($socket_2, $vector));
?>
--EXPECT--
bool(true)
bool(true)
bool(false)
int(1)
int(2)