mirror of
https://github.com/php/php-src.git
synced 2026-04-03 22:22:18 +02:00
Merge branch 'PHP-7.0'
This commit is contained in:
@@ -82,17 +82,15 @@ static inline spl_array_object *spl_array_from_obj(zend_object *obj) /* {{{ */ {
|
||||
|
||||
#define Z_SPLARRAY_P(zv) spl_array_from_obj(Z_OBJ_P((zv)))
|
||||
|
||||
static inline HashTable *spl_array_get_hash_table(spl_array_object* intern, int check_std_props) { /* {{{ */
|
||||
if (intern->ar_flags & SPL_ARRAY_IS_SELF
|
||||
|| (check_std_props && (intern->ar_flags & SPL_ARRAY_STD_PROP_LIST))
|
||||
) {
|
||||
static inline HashTable *spl_array_get_hash_table(spl_array_object* intern) { /* {{{ */
|
||||
if (intern->ar_flags & SPL_ARRAY_IS_SELF) {
|
||||
if (!intern->std.properties) {
|
||||
rebuild_object_properties(&intern->std);
|
||||
}
|
||||
return intern->std.properties;
|
||||
} else if (intern->ar_flags & SPL_ARRAY_USE_OTHER) {
|
||||
spl_array_object *other = Z_SPLARRAY_P(&intern->array);
|
||||
return spl_array_get_hash_table(other, check_std_props);
|
||||
return spl_array_get_hash_table(other);
|
||||
} else {
|
||||
return HASH_OF(&intern->array);
|
||||
}
|
||||
@@ -168,7 +166,7 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval *
|
||||
ZVAL_UNDEF(&intern->array);
|
||||
} else if (Z_OBJ_HT_P(orig) == &spl_handler_ArrayObject) {
|
||||
ZVAL_ARR(&intern->array,
|
||||
zend_array_dup(spl_array_get_hash_table(other, 0)));
|
||||
zend_array_dup(spl_array_get_hash_table(other)));
|
||||
} else {
|
||||
ZEND_ASSERT(Z_OBJ_HT_P(orig) == &spl_handler_ArrayIterator);
|
||||
ZVAL_COPY(&intern->array, orig);
|
||||
@@ -271,7 +269,7 @@ static zval *spl_array_get_dimension_ptr(int check_inherited, zval *object, zval
|
||||
zend_long index;
|
||||
zend_string *offset_key;
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
HashTable *ht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *ht = spl_array_get_hash_table(intern);
|
||||
|
||||
if (!offset || Z_ISUNDEF_P(offset)) {
|
||||
return &EG(uninitialized_zval);
|
||||
@@ -437,7 +435,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
|
||||
}
|
||||
|
||||
if (!offset) {
|
||||
ht = spl_array_get_hash_table(intern, 0);
|
||||
ht = spl_array_get_hash_table(intern);
|
||||
if (ht->u.v.nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
@@ -456,7 +454,7 @@ static void spl_array_write_dimension_ex(int check_inherited, zval *object, zval
|
||||
try_again:
|
||||
switch (Z_TYPE_P(offset)) {
|
||||
case IS_STRING:
|
||||
ht = spl_array_get_hash_table(intern, 0);
|
||||
ht = spl_array_get_hash_table(intern);
|
||||
if (ht->u.v.nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
@@ -478,7 +476,7 @@ try_again:
|
||||
case IS_LONG:
|
||||
index = Z_LVAL_P(offset);
|
||||
num_index:
|
||||
ht = spl_array_get_hash_table(intern, 0);
|
||||
ht = spl_array_get_hash_table(intern);
|
||||
if (ht->u.v.nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
@@ -486,7 +484,7 @@ num_index:
|
||||
zend_hash_index_update(ht, index, value);
|
||||
return;
|
||||
case IS_NULL:
|
||||
ht = spl_array_get_hash_table(intern, 0);
|
||||
ht = spl_array_get_hash_table(intern);
|
||||
if (ht->u.v.nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
@@ -523,7 +521,7 @@ static void spl_array_unset_dimension_ex(int check_inherited, zval *object, zval
|
||||
try_again:
|
||||
switch (Z_TYPE_P(offset)) {
|
||||
case IS_STRING:
|
||||
ht = spl_array_get_hash_table(intern, 0);
|
||||
ht = spl_array_get_hash_table(intern);
|
||||
if (ht->u.v.nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
@@ -572,7 +570,7 @@ try_again:
|
||||
case IS_LONG:
|
||||
index = Z_LVAL_P(offset);
|
||||
num_index:
|
||||
ht = spl_array_get_hash_table(intern, 0);
|
||||
ht = spl_array_get_hash_table(intern);
|
||||
if (ht->u.v.nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
@@ -620,7 +618,7 @@ static int spl_array_has_dimension_ex(int check_inherited, zval *object, zval *o
|
||||
}
|
||||
|
||||
if (!value) {
|
||||
HashTable *ht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *ht = spl_array_get_hash_table(intern);
|
||||
|
||||
try_again:
|
||||
switch (Z_TYPE_P(offset)) {
|
||||
@@ -746,7 +744,7 @@ SPL_METHOD(Array, offsetSet)
|
||||
void spl_array_iterator_append(zval *object, zval *append_value) /* {{{ */
|
||||
{
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
|
||||
if (!aht) {
|
||||
php_error_docref(NULL, E_NOTICE, "Array was modified outside object and is no longer an array");
|
||||
@@ -794,7 +792,7 @@ SPL_METHOD(Array, getArrayCopy)
|
||||
zval *object = getThis();
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
|
||||
RETURN_ARR(zend_array_dup(spl_array_get_hash_table(intern, 0)));
|
||||
RETURN_ARR(zend_array_dup(spl_array_get_hash_table(intern)));
|
||||
} /* }}} */
|
||||
|
||||
static HashTable *spl_array_get_properties(zval *object) /* {{{ */
|
||||
@@ -806,8 +804,15 @@ static HashTable *spl_array_get_properties(zval *object) /* {{{ */
|
||||
php_error_docref(NULL, E_ERROR, "Nesting level too deep - recursive dependency?");
|
||||
}
|
||||
|
||||
if (intern->ar_flags & SPL_ARRAY_STD_PROP_LIST) {
|
||||
if (!intern->std.properties) {
|
||||
rebuild_object_properties(&intern->std);
|
||||
}
|
||||
return intern->std.properties;
|
||||
}
|
||||
|
||||
intern->nApplyCount++;
|
||||
result = spl_array_get_hash_table(intern, 1);
|
||||
result = spl_array_get_hash_table(intern);
|
||||
intern->nApplyCount--;
|
||||
return result;
|
||||
} /* }}} */
|
||||
@@ -924,8 +929,8 @@ static int spl_array_compare_objects(zval *o1, zval *o2) /* {{{ */
|
||||
|
||||
intern1 = Z_SPLARRAY_P(o1);
|
||||
intern2 = Z_SPLARRAY_P(o2);
|
||||
ht1 = spl_array_get_hash_table(intern1, 0);
|
||||
ht2 = spl_array_get_hash_table(intern2, 0);
|
||||
ht1 = spl_array_get_hash_table(intern1);
|
||||
ht2 = spl_array_get_hash_table(intern2);
|
||||
|
||||
result = zend_compare_symbol_tables(ht1, ht2);
|
||||
/* if we just compared std.properties, don't do it again */
|
||||
@@ -980,7 +985,7 @@ static int spl_array_next_ex(spl_array_object *intern, HashTable *aht) /* {{{ */
|
||||
|
||||
static int spl_array_next(spl_array_object *intern) /* {{{ */
|
||||
{
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
|
||||
return spl_array_next_ex(intern, aht);
|
||||
|
||||
@@ -996,7 +1001,7 @@ static void spl_array_it_dtor(zend_object_iterator *iter) /* {{{ */
|
||||
static int spl_array_it_valid(zend_object_iterator *iter) /* {{{ */
|
||||
{
|
||||
spl_array_object *object = Z_SPLARRAY_P(&iter->data);
|
||||
HashTable *aht = spl_array_get_hash_table(object, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(object);
|
||||
|
||||
if (object->ar_flags & SPL_ARRAY_OVERLOADED_VALID) {
|
||||
return zend_user_it_valid(iter);
|
||||
@@ -1013,7 +1018,7 @@ static int spl_array_it_valid(zend_object_iterator *iter) /* {{{ */
|
||||
static zval *spl_array_it_get_current_data(zend_object_iterator *iter) /* {{{ */
|
||||
{
|
||||
spl_array_object *object = Z_SPLARRAY_P(&iter->data);
|
||||
HashTable *aht = spl_array_get_hash_table(object, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(object);
|
||||
|
||||
if (object->ar_flags & SPL_ARRAY_OVERLOADED_CURRENT) {
|
||||
return zend_user_it_get_current_data(iter);
|
||||
@@ -1030,7 +1035,7 @@ static zval *spl_array_it_get_current_data(zend_object_iterator *iter) /* {{{ */
|
||||
static void spl_array_it_get_current_key(zend_object_iterator *iter, zval *key) /* {{{ */
|
||||
{
|
||||
spl_array_object *object = Z_SPLARRAY_P(&iter->data);
|
||||
HashTable *aht = spl_array_get_hash_table(object, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(object);
|
||||
|
||||
if (object->ar_flags & SPL_ARRAY_OVERLOADED_KEY) {
|
||||
zend_user_it_get_current_key(iter, key);
|
||||
@@ -1047,7 +1052,7 @@ static void spl_array_it_get_current_key(zend_object_iterator *iter, zval *key)
|
||||
static void spl_array_it_move_forward(zend_object_iterator *iter) /* {{{ */
|
||||
{
|
||||
spl_array_object *object = Z_SPLARRAY_P(&iter->data);
|
||||
HashTable *aht = spl_array_get_hash_table(object, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(object);
|
||||
|
||||
if (object->ar_flags & SPL_ARRAY_OVERLOADED_NEXT) {
|
||||
zend_user_it_move_forward(iter);
|
||||
@@ -1065,7 +1070,7 @@ static void spl_array_it_move_forward(zend_object_iterator *iter) /* {{{ */
|
||||
|
||||
static void spl_array_rewind(spl_array_object *intern) /* {{{ */
|
||||
{
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
|
||||
if (!aht) {
|
||||
php_error_docref(NULL, E_NOTICE, "ArrayIterator::rewind(): Array was modified outside object and is no longer an array");
|
||||
@@ -1122,7 +1127,7 @@ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *ar
|
||||
} else {
|
||||
zend_object_get_properties_t handler = Z_OBJ_HANDLER_P(array, get_properties);
|
||||
if (handler != std_object_handlers.get_properties
|
||||
|| !spl_array_get_hash_table(intern, 0)) {
|
||||
|| !spl_array_get_hash_table(intern)) {
|
||||
ZVAL_UNDEF(&intern->array);
|
||||
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Overloaded object of type %s is not compatible with %s", Z_OBJCE_P(array)->name, intern->std.ce->name);
|
||||
}
|
||||
@@ -1286,7 +1291,7 @@ SPL_METHOD(Array, exchangeArray)
|
||||
return;
|
||||
}
|
||||
|
||||
RETVAL_ARR(zend_array_dup(spl_array_get_hash_table(intern, 0)));
|
||||
RETVAL_ARR(zend_array_dup(spl_array_get_hash_table(intern)));
|
||||
spl_array_set_array(object, intern, array, 0L, 1);
|
||||
}
|
||||
/* }}} */
|
||||
@@ -1297,7 +1302,7 @@ SPL_METHOD(Array, getIterator)
|
||||
{
|
||||
zval *object = getThis();
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
@@ -1334,7 +1339,7 @@ SPL_METHOD(Array, seek)
|
||||
zend_long opos, position;
|
||||
zval *object = getThis();
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
int result;
|
||||
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &position) == FAILURE) {
|
||||
@@ -1363,7 +1368,7 @@ SPL_METHOD(Array, seek)
|
||||
|
||||
int static spl_array_object_count_elements_helper(spl_array_object *intern, zend_long *count) /* {{{ */
|
||||
{
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
HashPosition pos, *pos_ptr;
|
||||
|
||||
if (!aht) {
|
||||
@@ -1428,7 +1433,7 @@ SPL_METHOD(Array, count)
|
||||
static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fname_len, int use_arg) /* {{{ */
|
||||
{
|
||||
spl_array_object *intern = Z_SPLARRAY_P(getThis());
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
zval function_name, params[2], *arg = NULL;
|
||||
uint32_t old_refcount;
|
||||
|
||||
@@ -1517,7 +1522,7 @@ SPL_METHOD(Array, current)
|
||||
zval *object = getThis();
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
zval *entry;
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
@@ -1555,7 +1560,7 @@ SPL_METHOD(Array, key)
|
||||
void spl_array_iterator_key(zval *object, zval *return_value) /* {{{ */
|
||||
{
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
|
||||
if (spl_array_object_verify_pos(intern, aht) == FAILURE) {
|
||||
return;
|
||||
@@ -1571,7 +1576,7 @@ SPL_METHOD(Array, next)
|
||||
{
|
||||
zval *object = getThis();
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
@@ -1591,7 +1596,7 @@ SPL_METHOD(Array, valid)
|
||||
{
|
||||
zval *object = getThis();
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
@@ -1611,7 +1616,7 @@ SPL_METHOD(Array, hasChildren)
|
||||
{
|
||||
zval *object = getThis(), *entry;
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
@@ -1635,7 +1640,7 @@ SPL_METHOD(Array, getChildren)
|
||||
{
|
||||
zval *object = getThis(), *entry, flags;
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
|
||||
if (zend_parse_parameters_none() == FAILURE) {
|
||||
return;
|
||||
@@ -1671,7 +1676,7 @@ SPL_METHOD(Array, serialize)
|
||||
{
|
||||
zval *object = getThis();
|
||||
spl_array_object *intern = Z_SPLARRAY_P(object);
|
||||
HashTable *aht = spl_array_get_hash_table(intern, 0);
|
||||
HashTable *aht = spl_array_get_hash_table(intern);
|
||||
zval members, flags;
|
||||
php_serialize_data_t var_hash;
|
||||
smart_str buf = {0};
|
||||
@@ -1741,7 +1746,7 @@ SPL_METHOD(Array, unserialize)
|
||||
return;
|
||||
}
|
||||
|
||||
aht = spl_array_get_hash_table(intern, 0);
|
||||
aht = spl_array_get_hash_table(intern);
|
||||
if (aht->u.v.nApplyCount > 0) {
|
||||
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
|
||||
return;
|
||||
|
||||
28
ext/spl/tests/ArrayObject_std_props_no_recursion.phpt
Normal file
28
ext/spl/tests/ArrayObject_std_props_no_recursion.phpt
Normal file
@@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
Don't recurse into USE_OTHER when checking for STD_PROP_LIST
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$a = new ArrayObject([1, 2, 3], ArrayObject::STD_PROP_LIST);
|
||||
$a->prop = 'a';
|
||||
$b = new ArrayObject($a, 0);
|
||||
$b->prop = 'b';
|
||||
var_dump((array) $b);
|
||||
$c = new ArrayObject($a);
|
||||
$c->prop = 'c';
|
||||
var_dump((array) $c);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
}
|
||||
array(1) {
|
||||
["prop"]=>
|
||||
string(1) "c"
|
||||
}
|
||||
Reference in New Issue
Block a user