summaryrefslogtreecommitdiff
path: root/ext/standard/streamsfuncs.c
diff options
context:
space:
mode:
authorGustavo André dos Santos Lopes <cataphract@php.net>2010-11-30 16:22:48 +0000
committerGustavo André dos Santos Lopes <cataphract@php.net>2010-11-30 16:22:48 +0000
commit22d461df621a1c059800a50c9d5c8bba41a14f16 (patch)
treea05c849788e65159e7c43f643b36e2124a0cc6d3 /ext/standard/streamsfuncs.c
parentc579738b9419d035967509cf3216e55d61f4c2fa (diff)
downloadphp-git-22d461df621a1c059800a50c9d5c8bba41a14f16.tar.gz
- Implemented bug/request #53427 - stream_select doesn't preserve the
keys. This cannot be backported to PHP 5.3 due to a BC break. See UPGRADING for more information.
Diffstat (limited to 'ext/standard/streamsfuncs.c')
-rw-r--r--ext/standard/streamsfuncs.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index 0ed8e10e6d..5f408f50d5 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -655,9 +655,21 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
zend_hash_init(new_hash, zend_hash_num_elements(Z_ARRVAL_P(stream_array)), NULL, ZVAL_PTR_DTOR, 0);
for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
- zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == SUCCESS;
+ zend_hash_has_more_elements(Z_ARRVAL_P(stream_array)) == SUCCESS;
zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
+ int type;
+ char *key;
+ uint key_len;
+ ulong num_ind;
+
+ type = zend_hash_get_current_key_ex(Z_ARRVAL_P(stream_array),
+ &key, &key_len, &num_ind, 0, NULL);
+ if (type == HASH_KEY_NON_EXISTANT ||
+ zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == FAILURE) {
+ continue; /* should not happen */
+ }
+
php_stream_from_zval_no_verify(stream, elem);
if (stream == NULL) {
continue;
@@ -669,7 +681,12 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
*/
if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd >= 0) {
if (PHP_SAFE_FD_ISSET(this_fd, fds)) {
- zend_hash_next_index_insert(new_hash, (void *)elem, sizeof(zval *), (void **)&dest_elem);
+ if (type == HASH_KEY_IS_LONG) {
+ zend_hash_index_update(new_hash, num_ind, (void *)elem, sizeof(zval *), (void **)&dest_elem);
+ } else { /* HASH_KEY_IS_STRING */
+ zend_hash_update(new_hash, key, key_len, (void *)elem, sizeof(zval *), (void **)&dest_elem);
+ }
+
if (dest_elem) {
zval_add_ref(dest_elem);
}