File php-5.2.6-arrayobject-mess.patch of Package php5

Index: ext/spl/spl_array.c
===================================================================
RCS file: /repository/php-src/ext/spl/spl_array.c,v
retrieving revision 1.71.2.17.2.15
retrieving revision 1.71.2.17.2.18
diff -u -p -r1.71.2.17.2.15 -r1.71.2.17.2.18
--- ext/spl/spl_array.c	31 Dec 2007 07:20:11 -0000	1.71.2.17.2.15
+++ ext/spl/spl_array.c	6 Oct 2008 13:45:42 -0000	1.71.2.17.2.18
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_array.c,v 1.71.2.17.2.15 2007/12/31 07:20:11 sebastian Exp $ */
+/* $Id: spl_array.c,v 1.71.2.17.2.18 2008/10/06 13:45:42 colder Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -255,6 +255,7 @@ static zval **spl_array_get_dimension_pt
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
 	zval **retval;
 	long index;
+	HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
 
 /*  We cannot get the pointer pointer so we don't allow it here for now
 	if (check_inherited && intern->fptr_offset_get) {
@@ -267,9 +268,17 @@ static zval **spl_array_get_dimension_pt
 	
 	switch(Z_TYPE_P(offset)) {
 	case IS_STRING:
-		if (zend_symtable_find(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &retval) == FAILURE) {
-			zend_error(E_NOTICE, "Undefined index:  %s", Z_STRVAL_P(offset));
-			return &EG(uninitialized_zval_ptr);
+		if (zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &retval) == FAILURE) {
+			if (type == BP_VAR_W || type == BP_VAR_RW) {
+				zval *value;
+				ALLOC_INIT_ZVAL(value);
+				zend_symtable_update(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void**)&value, sizeof(void*), NULL);
+				zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &retval);
+				return retval;
+			} else {
+				zend_error(E_NOTICE, "Undefined index:  %s", Z_STRVAL_P(offset));
+				return &EG(uninitialized_zval_ptr);
+			}
 		} else {
 			return retval;
 		}
@@ -282,9 +291,17 @@ static zval **spl_array_get_dimension_pt
 		} else {
 			index = Z_LVAL_P(offset);
 		}
-		if (zend_hash_index_find(spl_array_get_hash_table(intern, 0 TSRMLS_CC), index, (void **) &retval) == FAILURE) {
-			zend_error(E_NOTICE, "Undefined offset:  %ld", Z_LVAL_P(offset));
-			return &EG(uninitialized_zval_ptr);
+		if (zend_hash_index_find(ht, index, (void **) &retval) == FAILURE) {
+			if (type == BP_VAR_W || type == BP_VAR_RW) {
+				zval *value;
+				ALLOC_INIT_ZVAL(value);
+				zend_hash_index_update(ht, index, (void**)&value, sizeof(void*), NULL);
+				zend_hash_index_find(ht, index, (void **) &retval);
+				return retval;
+			} else {
+				zend_error(E_NOTICE, "Undefined offset:  %ld", Z_LVAL_P(offset));
+				return &EG(uninitialized_zval_ptr);
+			}
 		} else {
 			return retval;
 		}
@@ -1180,6 +1197,7 @@ static void spl_array_method(INTERNAL_FU
 	spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 	HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
 	zval tmp, *arg;
+	zval *retval_ptr = NULL;
 	
 	INIT_PZVAL(&tmp);
 	Z_TYPE(tmp) = IS_ARRAY;
@@ -1190,9 +1208,12 @@ static void spl_array_method(INTERNAL_FU
 			zend_throw_exception(spl_ce_BadMethodCallException, "Function expects exactly one argument", 0 TSRMLS_CC);
 			return;
 		}
-		zend_call_method(NULL, NULL, NULL, fname, fname_len, &return_value, 2, &tmp, arg TSRMLS_CC);
+		zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 2, &tmp, arg TSRMLS_CC);
 	} else {
-		zend_call_method(NULL, NULL, NULL, fname, fname_len, &return_value, 1, &tmp, NULL TSRMLS_CC);
+		zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 1, &tmp, NULL TSRMLS_CC);
+	}
+	if (retval_ptr) {
+		COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
 	}
 }
 
Index: ext/spl/spl_directory.c
===================================================================
RCS file: /repository/php-src/ext/spl/spl_directory.c,v
retrieving revision 1.45.2.27.2.26
retrieving revision 1.45.2.27.2.29
diff -u -p -r1.45.2.27.2.26 -r1.45.2.27.2.29
--- ext/spl/spl_directory.c	13 Feb 2008 12:23:26 -0000	1.45.2.27.2.26
+++ ext/spl/spl_directory.c	11 Sep 2008 15:32:15 -0000	1.45.2.27.2.29
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.45.2.27.2.26 2008/02/13 12:23:26 helly Exp $ */
+/* $Id: spl_directory.c,v 1.45.2.27.2.29 2008/09/11 15:32:15 lbarnaud Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -426,6 +426,7 @@ static spl_filesystem_object * spl_files
 					&use_include_path, &intern->u.file.zcontext) == FAILURE) {
 				php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 				intern->u.file.open_mode = NULL;
+				intern->file_name = NULL;
 				zval_dtor(return_value);
 				Z_TYPE_P(return_value) = IS_NULL;
 				return NULL;
@@ -1055,7 +1056,7 @@ SPL_METHOD(RecursiveDirectoryIterator, g
 	INIT_PZVAL(&zpath);
 	ZVAL_STRINGL(&zpath, intern->file_name, intern->file_name_len, 0);
 
-	spl_instantiate_arg_ex1(spl_ce_RecursiveDirectoryIterator, &return_value, 0, &zpath TSRMLS_CC);
+	spl_instantiate_arg_ex1(Z_OBJCE_P(getThis()), &return_value, 0, &zpath TSRMLS_CC);
 	
 	subdir = (spl_filesystem_object*)zend_object_store_get_object(return_value TSRMLS_CC);
 	if (subdir) {
@@ -2214,7 +2215,9 @@ SPL_METHOD(SplFileObject, seek)
 	spl_filesystem_file_rewind(getThis(), intern TSRMLS_CC);
 	
 	while(intern->u.file.current_line_num < line_pos) {
-		spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC);
+		if (spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC) == FAILURE) {
+			break;
+		}
 	}
 } /* }}} */
 
Index: ext/spl/spl_iterators.c
===================================================================
RCS file: /repository/php-src/ext/spl/spl_iterators.c,v
retrieving revision 1.73.2.30.2.31
retrieving revision 1.73.2.30.2.33
diff -u -p -r1.73.2.30.2.31 -r1.73.2.30.2.33
--- ext/spl/spl_iterators.c	12 Mar 2008 13:24:24 -0000	1.73.2.30.2.31
+++ ext/spl/spl_iterators.c	22 Sep 2008 13:15:16 -0000	1.73.2.30.2.33
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_iterators.c,v 1.73.2.30.2.31 2008/03/12 13:24:24 colder Exp $ */
+/* $Id: spl_iterators.c,v 1.73.2.30.2.33 2008/09/22 13:15:16 felipe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -1118,6 +1118,9 @@ static inline void spl_dual_it_rewind(sp
 
 static inline int spl_dual_it_valid(spl_dual_it_object *intern TSRMLS_DC)
 {
+	if (!intern->inner.iterator) {
+		return FAILURE;
+	}
 	/* FAILURE / SUCCESS */
 	return intern->inner.iterator->funcs->valid(intern->inner.iterator TSRMLS_CC);
 }
@@ -1360,6 +1363,10 @@ SPL_METHOD(RegexIterator, accept)
 	int        subject_len, use_copy, count, result_len;
 	zval       subject_copy, zcount, *replacement;
 
+	if (intern->current.data == NULL) {
+		RETURN_FALSE;
+	}
+
 	if (intern->u.regex.flags & REGIT_USE_KEY) {
 		if (intern->current.key_type == HASH_KEY_IS_LONG) {
 			subject_len = slprintf(tmp, sizeof(tmp), "%ld", intern->current.int_key);
Index: ext/spl/examples/tests/dualiterator_001.phpt
===================================================================
RCS file: /repository/php-src/ext/spl/examples/tests/dualiterator_001.phpt,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -u -p -r1.2.2.3 -r1.2.2.4
--- ext/spl/examples/tests/dualiterator_001.phpt	10 Dec 2006 23:44:49 -0000	1.2.2.3
+++ ext/spl/examples/tests/dualiterator_001.phpt	14 Aug 2008 23:46:55 -0000	1.2.2.4
@@ -1,7 +1,7 @@
 --TEST--
 SPL: DualIterator
 --SKIPIF--
-<?php if (!extension_loaded("spl")) print "skip"; ?>
+<?php if (!extension_loaded("spl") || !extension_loaded("reflection")) print "skip"; ?>
 --FILE--
 <?php
 
Index: ext/spl/tests/dit_002.phpt
===================================================================
RCS file: /repository/php-src/ext/spl/tests/dit_002.phpt,v
retrieving revision 1.1.4.2
retrieving revision 1.1.4.3
diff -u -p -r1.1.4.2 -r1.1.4.3
--- ext/spl/tests/dit_002.phpt	13 Feb 2008 12:23:26 -0000	1.1.4.2
+++ ext/spl/tests/dit_002.phpt	14 Aug 2008 23:46:55 -0000	1.1.4.3
@@ -1,7 +1,7 @@
 --TEST--
 SPL: DirectoryIterator defaults
 --SKIPIF--
-<?php if (!extension_loaded("spl")) print "skip"; ?>
+<?php if (!extension_loaded("spl") || !extension_loaded('reflection')) print "skip"; ?>
 --FILE--
 <?php
 
openSUSE Build Service is sponsored by