mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
Fixed bug (count on symbol tables)
This commit is contained in:
parent
31d93fcf4b
commit
eada2aa91a
1
NEWS
1
NEWS
@ -27,6 +27,7 @@ PHP NEWS
|
|||||||
. Fixed bug #70940 (Segfault in soap / type_to_string). (Remi)
|
. Fixed bug #70940 (Segfault in soap / type_to_string). (Remi)
|
||||||
|
|
||||||
- Standard:
|
- Standard:
|
||||||
|
. Fixed bug (count on symbol tables). (Laruence)
|
||||||
. Fixed bug #70910 (extract() breaks variable references). (Laruence)
|
. Fixed bug #70910 (extract() breaks variable references). (Laruence)
|
||||||
|
|
||||||
- Streams/Socket
|
- Streams/Socket
|
||||||
|
@ -757,6 +757,41 @@ PHP_FUNCTION(ksort)
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
static uint32_t php_array_recalc_elements(HashTable *ht) /* {{{ */
|
||||||
|
{
|
||||||
|
zval *val;
|
||||||
|
uint32_t num = ht->nNumOfElements;
|
||||||
|
|
||||||
|
ZEND_HASH_FOREACH_VAL(ht, val) {
|
||||||
|
if (Z_TYPE_P(val) == IS_UNDEF) continue;
|
||||||
|
if (Z_TYPE_P(val) == IS_INDIRECT) {
|
||||||
|
if (Z_TYPE_P(Z_INDIRECT_P(val)) == IS_UNDEF) {
|
||||||
|
num--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ZEND_HASH_FOREACH_END();
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
|
static uint32_t php_array_num_elements(zval *arr) /* {{{ */
|
||||||
|
{
|
||||||
|
uint32_t num;
|
||||||
|
HashTable *ht = Z_ARRVAL_P(arr);
|
||||||
|
if (UNEXPECTED(Z_SYMBOLTABLE_P(arr))) {
|
||||||
|
num = php_array_recalc_elements(ht);
|
||||||
|
} else if (UNEXPECTED(ht->u.v.flags & HASH_FLAG_HAS_EMPTY_IND)) {
|
||||||
|
num = php_array_recalc_elements(ht);
|
||||||
|
if (UNEXPECTED(ht->nNumOfElements == num)) {
|
||||||
|
ht->u.v.flags &= ~HASH_FLAG_HAS_EMPTY_IND;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
num = zend_hash_num_elements(ht);
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
/* }}} */
|
||||||
|
|
||||||
PHPAPI zend_long php_count_recursive(zval *array, zend_long mode) /* {{{ */
|
PHPAPI zend_long php_count_recursive(zval *array, zend_long mode) /* {{{ */
|
||||||
{
|
{
|
||||||
zend_long cnt = 0;
|
zend_long cnt = 0;
|
||||||
@ -768,7 +803,7 @@ PHPAPI zend_long php_count_recursive(zval *array, zend_long mode) /* {{{ */
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cnt = zend_hash_num_elements(Z_ARRVAL_P(array));
|
cnt = php_array_num_elements(array);
|
||||||
if (mode == COUNT_RECURSIVE) {
|
if (mode == COUNT_RECURSIVE) {
|
||||||
if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(array))) {
|
if (ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P(array))) {
|
||||||
Z_ARRVAL_P(array)->u.v.nApplyCount++;
|
Z_ARRVAL_P(array)->u.v.nApplyCount++;
|
||||||
@ -813,7 +848,7 @@ PHP_FUNCTION(count)
|
|||||||
RETURN_LONG(0);
|
RETURN_LONG(0);
|
||||||
break;
|
break;
|
||||||
case IS_ARRAY:
|
case IS_ARRAY:
|
||||||
cnt = zend_hash_num_elements(Z_ARRVAL_P(array));
|
cnt = php_array_num_elements(array);
|
||||||
if (mode == COUNT_RECURSIVE) {
|
if (mode == COUNT_RECURSIVE) {
|
||||||
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array), element) {
|
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array), element) {
|
||||||
ZVAL_DEREF(element);
|
ZVAL_DEREF(element);
|
||||||
|
Loading…
Reference in New Issue
Block a user