helly           Wed Jul 16 06:41:44 2003 EDT

  Modified files:              
    /spl        spl_array.c 
    /spl/tests  array_access_001.phpt array_access_002.phpt 
  Log:
  Make array write stuff work again correct and fix tests
  
Index: spl/spl_array.c
diff -u spl/spl_array.c:1.7 spl/spl_array.c:1.8
--- spl/spl_array.c:1.7 Wed Jul 16 05:48:36 2003
+++ spl/spl_array.c     Wed Jul 16 06:41:43 2003
@@ -218,9 +218,18 @@
 
                FREE_OP(Ts, op2, EG(free_op2));
                if (&EX(opline)->result) {
-                       EX_T(EX(opline)->result.u.var).var.ptr = retval;
-                       EX_T(EX(opline)->result.u.var).var.ptr_ptr = 
NULL;/*&EX_T(EX(opline)->result.u.var).var.ptr;*/
-                       SELECTIVE_PZVAL_LOCK(retval, &EX(opline)->result);
+                       if (retval->refcount < 2) {
+                               zend_error(E_WARNING, "Method %s::set() did not return 
a value, using input value", obj_ce->name);
+                               EX_T(EX(opline)->result.u.var).var.ptr = value;
+                               SELECTIVE_PZVAL_LOCK(value, &EX(opline)->result);
+                               DELETE_RET_ZVAL(retval);                        
+                       } else {
+                               EX_T(EX(opline)->result.u.var).var.ptr = retval;
+                               retval->refcount--;
+                       }
+                       EX_T(EX(opline)->result.u.var).var.ptr_ptr = NULL;
+               } else {
+                       DELETE_RET_ZVAL(retval);                        
                }
 
                EX(opline)++;
Index: spl/tests/array_access_001.phpt
diff -u spl/tests/array_access_001.phpt:1.2 spl/tests/array_access_001.phpt:1.3
--- spl/tests/array_access_001.phpt:1.2 Wed Jun  4 16:54:13 2003
+++ spl/tests/array_access_001.phpt     Wed Jul 16 06:41:43 2003
@@ -82,32 +82,28 @@
 int(4)
 c::exists(5th)
 
-Notice: Undefined index:  5th in %s on line %d
+Notice: Undefined index:  5th in %sarray_access_001.php on line %d
 NULL
 c::exists(6)
 
-Notice: Undefined index:  6 in %s on line %d
+Notice: Undefined index:  6 in %sarray_access_001.php on line %d
 NULL
 WRITE 1
-c::exists(1)
 c::set(1,Changed 1)
 c::exists(1)
 c::get(1)
 string(9) "Changed 1"
 WRITE 2
-c::exists(4th)
 c::set(4th,Changed 4th)
 c::exists(4th)
 c::get(4th)
 string(11) "Changed 4th"
 WRITE 3
-c::exists(5th)
 c::set(5th,Added 5th)
 c::exists(5th)
 c::get(5th)
 string(9) "Added 5th"
 WRITE 4
-c::exists(6)
 c::set(6,Added 6)
 c::exists(6)
 c::get(6)
@@ -118,7 +114,6 @@
 c::exists(2)
 c::get(2)
 string(3) "3rd"
-c::exists(6)
 c::set(6,changed 6)
 c::exists(6)
 c::get(6)
Index: spl/tests/array_access_002.phpt
diff -u spl/tests/array_access_002.phpt:1.2 spl/tests/array_access_002.phpt:1.3
--- spl/tests/array_access_002.phpt:1.2 Wed Jun  4 16:54:13 2003
+++ spl/tests/array_access_002.phpt     Wed Jul 16 06:41:43 2003
@@ -10,6 +10,7 @@
 class c implements spl_array_access {
 
        public $a = array('1st', 1, 2=>'3rd', '4th'=>4);
+
        function exists($index) {
                echo __METHOD__ . "($index)\n";
                return array_key_exists($index, $this->a);
@@ -82,41 +83,37 @@
 int(4)
 c::exists(5th)
 
-Notice: Undefined index:  5th in %s on line %d
+Notice: Undefined index:  5th in %sarray_access_002.php on line %d
 NULL
 c::exists(6)
 
-Notice: Undefined index:  6 in %s on line %d
+Notice: Undefined index:  6 in %sarray_access_002.php on line %d
 NULL
 WRITE 1
-c::exists(1)
 c::set(1,Changed 1)
 
-Warning: Method c::set() did not return a value, using NULL in %s on line %d
+Warning: Method c::set() did not return a value, using input value in 
%sarray_access_002.php on line %d
 c::exists(1)
 c::get(1)
 string(9) "Changed 1"
 WRITE 2
-c::exists(4th)
 c::set(4th,Changed 4th)
 
-Warning: Method c::set() did not return a value, using NULL in %s on line %d
+Warning: Method c::set() did not return a value, using input value in 
%sarray_access_002.php on line %d
 c::exists(4th)
 c::get(4th)
 string(11) "Changed 4th"
 WRITE 3
-c::exists(5th)
 c::set(5th,Added 5th)
 
-Warning: Method c::set() did not return a value, using NULL in %s on line %d
+Warning: Method c::set() did not return a value, using input value in 
%sarray_access_002.php on line %d
 c::exists(5th)
 c::get(5th)
 string(9) "Added 5th"
 WRITE 4
-c::exists(6)
 c::set(6,Added 6)
 
-Warning: Method c::set() did not return a value, using NULL in %s on line %d
+Warning: Method c::set() did not return a value, using input value in 
%sarray_access_002.php on line %d
 c::exists(6)
 c::get(6)
 string(7) "Added 6"
@@ -126,12 +123,11 @@
 c::exists(2)
 c::get(2)
 string(3) "3rd"
-c::exists(6)
 c::set(6,changed 6)
 
-Warning: Method c::set() did not return a value, using NULL in %s on line %d
+Warning: Method c::set() did not return a value, using input value in 
%sarray_access_002.php on line %d
 c::exists(6)
 c::get(6)
 string(9) "changed 6"
-NULL
+string(9) "changed 6"
 Done



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to