From: Derick Rethans Date: Fri, 17 Dec 2004 14:38:45 +0000 (+0000) Subject: - Fixed bug #31072 (var_export() does not output an array element with an empty X-Git-Tag: php-4.3.11RC1~255 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec34a3876aadc3185bdc9048f9362e562c966495;p=php - Fixed bug #31072 (var_export() does not output an array element with an empty string key). (Derick) --- diff --git a/NEWS b/NEWS index 877f89df9e..bf67f0683e 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ PHP 4 NEWS - Fixed bug #31111 (Compile failure of zend_strtod.c). (Derick) - Fixed bug #31110 (PHP 4.3.10 does not compile on Tru64 UNIX 5.1B). (Derick) - Fixed bug #31107 (Compile failure on Solaris 9 (Intel) and gcc 3.4.3). (Derick) +- Fixed bug #31072 (var_export() does not output an array element with an empty + string key). (Derick) - Fixed bug #31056 (php_std_date() returns invalid formatted date if y2k_compliance is On). (Ilia) diff --git a/ext/standard/tests/array/var_export2.phpt b/ext/standard/tests/array/var_export2.phpt new file mode 100644 index 0000000000..2b8a1f97ef Binary files /dev/null and b/ext/standard/tests/array/var_export2.phpt differ diff --git a/ext/standard/var.c b/ext/standard/var.c index 632abf327b..1cb274c18d 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -267,17 +267,13 @@ static int php_array_element_export(zval **zv, int num_args, va_list args, zend_ if (hash_key->nKeyLength==0) { /* numeric key */ php_printf("%*c%ld => ", level + 1, ' ', hash_key->h); } else { /* string key */ - if (va_arg(args, int) && hash_key->arKey[0] == '\0') { - return 0; - } else { - char *key; - int key_len; - key = php_addcslashes(hash_key->arKey, hash_key->nKeyLength - 1, &key_len, 0, "'\\", 2 TSRMLS_CC); - php_printf("%*c'", level + 1, ' '); - PHPWRITE(key, key_len); - php_printf("' => "); - efree(key); - } + char *key; + int key_len; + key = php_addcslashes(hash_key->arKey, hash_key->nKeyLength - 1, &key_len, 0, "'\\", 2 TSRMLS_CC); + php_printf("%*c'", level + 1, ' '); + PHPWRITE(key, key_len); + php_printf("' => "); + efree(key); } php_var_export(zv, level + 2 TSRMLS_CC); PUTS (",\n");