Skip to content

Commit

Permalink
Fixed bug #75653
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jan 12, 2018
1 parent f8c8897 commit 8c73fc8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ PHP NEWS

- Standard:
. Fixed bug #75781 (substr_count incorrect result). (Laruence)
. Fixed bug #75653 (array_values don't work on empty array). (Nikita)

- Zip:
. Display headers (buildtime) and library (runtime) versions in phpinfo
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -4028,7 +4028,7 @@ PHP_FUNCTION(array_values)

/* Return empty input as is */
arrlen = zend_hash_num_elements(arrval);
if (!arrlen) {
if (!arrlen && arrval->nNextFreeElement == arrlen) {
RETURN_ZVAL(input, 1, 0);
}

Expand Down
20 changes: 20 additions & 0 deletions ext/standard/tests/array/bug75653.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Bug #75653: array_values don't work on empty array
--FILE--
<?php

$array[] = 'data1';
unset($array[0]);
$array = array_values($array);
$array[] = 'data2';
$array[] = 'data3';
var_dump($array);

?>
--EXPECT--
array(2) {
[0]=>
string(5) "data2"
[1]=>
string(5) "data3"
}

0 comments on commit 8c73fc8

Please sign in to comment.