Merge branch 'PHP-7.0' into PHP-7.1

This commit is contained in:
Nikita Popov 2017-02-02 18:33:26 +01:00
commit e81f30ad1d
4 changed files with 45 additions and 2 deletions

2
NEWS
View file

@ -5,6 +5,8 @@ PHP NEWS
- Core:
. Fixed bug #73807 (Performance problem with processing large post request).
(Nikita)
. Fixed bug #73998 (array_key_exists fails on arrays created by
get_object_vars). (mhagstrand)
- GD:
. Fixed bug #74031 (ReflectionFunction for imagepng is missing last two

19
Zend/tests/bug73998.phpt Normal file
View file

@ -0,0 +1,19 @@
--TEST--
Bug #73998 (array_key_exists fails on arrays created by get_object_vars)
--DESCRIPTION--
Properties of objects with numeric names should be accessible
--FILE--
<?php
$a = new stdClass;
$a->{1234} = "Numeric";
$a->a1234 = "String";
$properties = get_object_vars($a);
var_dump(array_key_exists(1234, $properties));
echo "Value: {$properties[1234]}\n";
?>
--EXPECT--
bool(true)
Value: Numeric

View file

@ -1223,6 +1223,8 @@ ZEND_FUNCTION(get_object_vars)
HashTable *properties;
zend_string *key;
zend_object *zobj;
zend_ulong index;
zend_bool fast_copy = 0;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_OBJECT(obj)
@ -1241,7 +1243,17 @@ ZEND_FUNCTION(get_object_vars)
zobj = Z_OBJ_P(obj);
if (!zobj->ce->default_properties_count && properties == zobj->properties && !ZEND_HASH_GET_APPLY_COUNT(properties)) {
/* fast copy */
fast_copy = 1;
/* Check if the object has a numeric property, See Bug 73998 */
ZEND_HASH_FOREACH_STR_KEY(properties, key) {
if (key && ZEND_HANDLE_NUMERIC(key, index)) {
fast_copy = 0;
break;
}
} ZEND_HASH_FOREACH_END();
}
if (fast_copy) {
if (EXPECTED(zobj->handlers == &std_object_handlers)) {
if (EXPECTED(!(GC_FLAGS(properties) & IS_ARRAY_IMMUTABLE))) {
GC_REFCOUNT(properties)++;
@ -1267,7 +1279,7 @@ ZEND_FUNCTION(get_object_vars)
zend_unmangle_property_name_ex(key, &class_name, &prop_name, &prop_len);
zend_hash_str_add_new(Z_ARRVAL_P(return_value), prop_name, prop_len, value);
} else {
zend_hash_add_new(Z_ARRVAL_P(return_value), key, value);
zend_symbtable_add_new(Z_ARRVAL_P(return_value), key, value);
}
}
}

View file

@ -337,6 +337,16 @@ static zend_always_inline int zend_hash_str_exists_ind(const HashTable *ht, cons
Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF);
}
static zend_always_inline zval *zend_symbtable_add_new(HashTable *ht, zend_string *key, zval *pData)
{
zend_ulong idx;
if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_add_new(ht, idx, pData);
} else {
return zend_hash_add_new(ht, key, pData);
}
}
static zend_always_inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData)
{