Merge branch 'PHP-8.0' into PHP-8.1

This commit is contained in:
Arnaud Le Blanc 2022-07-15 13:15:05 +02:00
commit aadb24e817
3 changed files with 38 additions and 0 deletions

2
NEWS
View file

@ -8,6 +8,8 @@ PHP NEWS
- Core: - Core:
. Fixed bug GH-8923 (error_log on Windows can hold the file write lock). (cmb) . Fixed bug GH-8923 (error_log on Windows can hold the file write lock). (cmb)
. Fixed bug GH-8995 (WeakMap object reference offset causing TypeError).
(Tobias Bachert)
- CLI: - CLI:
. Fixed GH-8952 (Intentionally closing std handles no longer possible). . Fixed GH-8952 (Intentionally closing std handles no longer possible).

View file

@ -0,0 +1,32 @@
--TEST--
WeakMap object reference offset
--FILE--
<?php
$map = new WeakMap;
$obj = new stdClass;
$obj2 = &$obj;
$map[$obj] = 1;
var_dump(count($map));
var_dump($map);
var_dump(isset($map[$obj]));
var_dump(!empty($map[$obj]));
var_dump($map[$obj]);
?>
--EXPECT--
int(1)
object(WeakMap)#1 (1) {
[0]=>
array(2) {
["key"]=>
object(stdClass)#2 (0) {
}
["value"]=>
int(1)
}
}
bool(true)
bool(true)
int(1)

View file

@ -310,6 +310,7 @@ static zval *zend_weakmap_read_dimension(zend_object *object, zval *offset, int
return NULL; return NULL;
} }
ZVAL_DEREF(offset);
if (Z_TYPE_P(offset) != IS_OBJECT) { if (Z_TYPE_P(offset) != IS_OBJECT) {
zend_type_error("WeakMap key must be an object"); zend_type_error("WeakMap key must be an object");
return NULL; return NULL;
@ -340,6 +341,7 @@ static void zend_weakmap_write_dimension(zend_object *object, zval *offset, zval
return; return;
} }
ZVAL_DEREF(offset);
if (Z_TYPE_P(offset) != IS_OBJECT) { if (Z_TYPE_P(offset) != IS_OBJECT) {
zend_type_error("WeakMap key must be an object"); zend_type_error("WeakMap key must be an object");
return; return;
@ -367,6 +369,7 @@ static void zend_weakmap_write_dimension(zend_object *object, zval *offset, zval
/* int return and check_empty due to Object Handler API */ /* int return and check_empty due to Object Handler API */
static int zend_weakmap_has_dimension(zend_object *object, zval *offset, int check_empty) static int zend_weakmap_has_dimension(zend_object *object, zval *offset, int check_empty)
{ {
ZVAL_DEREF(offset);
if (Z_TYPE_P(offset) != IS_OBJECT) { if (Z_TYPE_P(offset) != IS_OBJECT) {
zend_type_error("WeakMap key must be an object"); zend_type_error("WeakMap key must be an object");
return 0; return 0;
@ -386,6 +389,7 @@ static int zend_weakmap_has_dimension(zend_object *object, zval *offset, int che
static void zend_weakmap_unset_dimension(zend_object *object, zval *offset) static void zend_weakmap_unset_dimension(zend_object *object, zval *offset)
{ {
ZVAL_DEREF(offset);
if (Z_TYPE_P(offset) != IS_OBJECT) { if (Z_TYPE_P(offset) != IS_OBJECT) {
zend_type_error("WeakMap key must be an object"); zend_type_error("WeakMap key must be an object");
return; return;