Revision: http://svn.php.net/viewvc?view=revision&revision=302838
Log:
Implemented request #34857 (Change array_combine behaviour when called with
empty arrays). Patch by Joel Perras <joel....@gmail.com>.
Bug: http://bugs.php.net/34857 (Assigned) Change array_combine behavoiur
Changed paths:
U php/php-src/trunk/NEWS
U php/php-src/trunk/UPGRADING
U php/php-src/trunk/ext/standard/array.c
U php/php-src/trunk/ext/standard/tests/array/array_combine_error2.phpt
U php/php-src/trunk/ext/standard/tests/array/array_combine_variation3.phpt
U php/php-src/trunk/ext/standard/tests/array/array_combine_variation4.phpt
U php/php-src/trunk/ext/standard/tests/array/array_combine_variation5.phpt
Modified: php/php-src/trunk/NEWS
===================================================================
--- php/php-src/trunk/NEWS 2010-08-27 02:42:44 UTC (rev 302837)
+++ php/php-src/trunk/NEWS 2010-08-27 03:54:10 UTC (rev 302838)
@@ -101,6 +101,8 @@
at gmail dot com, Pierre)
- Implemented FR #42060 (Add paged Results support). (an...@OpenLDAP.org,
iare...@eteo.mondragon.edu, jea...@au-fil-du.net, remy....@gmail.com)
+- Implemented FR #34857 (Change array_combine behaviour when called with empty
+ arrays). (joel....@gmail.com)
- Fixed PDO objects binary incompatibility. (Dmitry)
Modified: php/php-src/trunk/UPGRADING
===================================================================
--- php/php-src/trunk/UPGRADING 2010-08-27 02:42:44 UTC (rev 302837)
+++ php/php-src/trunk/UPGRADING 2010-08-27 03:54:10 UTC (rev 302838)
@@ -90,7 +90,8 @@
3. Changes made to existing functions
=====================================
--
+- array_combine now returns array() instead of FALSE when two empty arrays are
+ provided as parameters.
===================================
4. Changes made to existing methods
Modified: php/php-src/trunk/ext/standard/array.c
===================================================================
--- php/php-src/trunk/ext/standard/array.c 2010-08-27 02:42:44 UTC (rev 302837)
+++ php/php-src/trunk/ext/standard/array.c 2010-08-27 03:54:10 UTC (rev 302838)
@@ -4481,13 +4481,12 @@
RETURN_FALSE;
}
+ array_init_size(return_value, num_keys);
+
if (!num_keys) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Both parameters should have at least 1 element");
- RETURN_FALSE;
+ return;
}
- array_init_size(return_value, num_keys);
-
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(keys), &pos_keys);
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(values), &pos_values);
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(keys), (void **)&entry_keys, &pos_keys) == SUCCESS &&
Modified: php/php-src/trunk/ext/standard/tests/array/array_combine_error2.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/array/array_combine_error2.phpt 2010-08-27 02:42:44 UTC (rev 302837)
+++ php/php-src/trunk/ext/standard/tests/array/array_combine_error2.phpt 2010-08-27 03:54:10 UTC (rev 302838)
@@ -32,10 +32,9 @@
*** Testing array_combine() : error conditions specific to array_combine() ***
-- Testing array_combine() function with empty arrays --
+array(0) {
+}
-Warning: array_combine(): Both parameters should have at least 1 element in %s on line %d
-bool(false)
-
-- Testing array_combine() function with empty array for $keys argument --
Warning: array_combine(): Both parameters should have an equal number of elements in %s on line %d
Modified: php/php-src/trunk/ext/standard/tests/array/array_combine_variation3.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/array/array_combine_variation3.phpt 2010-08-27 02:42:44 UTC (rev 302837)
+++ php/php-src/trunk/ext/standard/tests/array/array_combine_variation3.phpt 2010-08-27 03:54:10 UTC (rev 302838)
@@ -108,9 +108,8 @@
bool(true)
}
-- Iteration 4 --
-
-Warning: array_combine(): Both parameters should have at least 1 element in %s on line %d
-bool(false)
+array(0) {
+}
-- Iteration 5 --
array(1) {
[""]=>
Modified: php/php-src/trunk/ext/standard/tests/array/array_combine_variation4.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/array/array_combine_variation4.phpt 2010-08-27 02:42:44 UTC (rev 302837)
+++ php/php-src/trunk/ext/standard/tests/array/array_combine_variation4.phpt 2010-08-27 03:54:10 UTC (rev 302838)
@@ -100,9 +100,8 @@
Warning: Illegal offset type in %s on line %d
-- Iteration 1 --
-
-Warning: array_combine(): Both parameters should have at least 1 element in %s on line %d
-bool(false)
+array(0) {
+}
-- Iteration 2 --
array(1) {
[0]=>
Modified: php/php-src/trunk/ext/standard/tests/array/array_combine_variation5.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/array/array_combine_variation5.phpt 2010-08-27 02:42:44 UTC (rev 302837)
+++ php/php-src/trunk/ext/standard/tests/array/array_combine_variation5.phpt 2010-08-27 03:54:10 UTC (rev 302838)
@@ -82,9 +82,8 @@
--EXPECTF--
*** Testing array_combine() : assoc array with diff values to both $keys and $values argument ***
-- Iteration 1 --
-
-Warning: array_combine(): Both parameters should have at least 1 element in %s on line %d
-bool(false)
+array(0) {
+}
-- Iteration 2 --
array(1) {
[0]=>