magicaltux              Thu Nov 20 15:55:00 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/wddx/tests     002.phpt 003.phpt 004.phpt 005.phpt 

  Modified files:              
    /php-src/ext/wddx   wddx.c 
  Log:
  - MFH: ext/wddx: classes providing __sleep() are stored without properties 
(fixed)
  - ext/wddx: fixed wddx_add_vars() ignoring first var in php 5.3
  
http://cvs.php.net/viewvc.cgi/php-src/ext/wddx/wddx.c?r1=1.119.2.10.2.17.2.16&r2=1.119.2.10.2.17.2.17&diff_format=u
Index: php-src/ext/wddx/wddx.c
diff -u php-src/ext/wddx/wddx.c:1.119.2.10.2.17.2.16 
php-src/ext/wddx/wddx.c:1.119.2.10.2.17.2.17
--- php-src/ext/wddx/wddx.c:1.119.2.10.2.17.2.16        Thu Nov 20 14:48:41 2008
+++ php-src/ext/wddx/wddx.c     Thu Nov 20 15:55:00 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: wddx.c,v 1.119.2.10.2.17.2.16 2008/11/20 14:48:41 felipe Exp $ */
+/* $Id: wddx.c,v 1.119.2.10.2.17.2.17 2008/11/20 15:55:00 magicaltux Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -460,7 +460,7 @@
        char *key;
        ulong idx;
        char tmp_buf[WDDX_BUF_LEN];
-       HashTable *objhash;
+       HashTable *objhash, *sleephash;
        TSRMLS_FETCH();
 
        MAKE_STD_ZVAL(fname);
@@ -471,7 +471,7 @@
         * array of property names to be serialized.
         */
        if (call_user_function_ex(CG(function_table), &obj, fname, &retval, 0, 
0, 1, NULL TSRMLS_CC) == SUCCESS) {
-               if (retval && (objhash = HASH_OF(retval))) {
+               if (retval && (sleephash = HASH_OF(retval))) {
                        PHP_CLASS_ATTRIBUTES;
                        
                        PHP_SET_CLASS_ATTRIBUTES(obj);
@@ -485,10 +485,12 @@
                        php_wddx_add_chunk_static(packet, WDDX_VAR_E);
 
                        PHP_CLEANUP_CLASS_ATTRIBUTES();
+
+                       objhash = HASH_OF(obj);
                        
-                       for (zend_hash_internal_pointer_reset(objhash);
-                                zend_hash_get_current_data(objhash, (void 
**)&varname) == SUCCESS;
-                                zend_hash_move_forward(objhash)) {
+                       for (zend_hash_internal_pointer_reset(sleephash);
+                                zend_hash_get_current_data(sleephash, (void 
**)&varname) == SUCCESS;
+                                zend_hash_move_forward(sleephash)) {
                                if (Z_TYPE_PP(varname) != IS_STRING) {
                                        php_error_docref(NULL TSRMLS_CC, 
E_NOTICE, "__sleep should return an array only containing the names of 
instance-variables to serialize.");
                                        continue;
@@ -692,7 +694,7 @@
        zval **val;
        HashTable *target_hash;
        TSRMLS_FETCH();
-       
+
        if (Z_TYPE_P(name_var) == IS_STRING) {
                if (!EG(active_symbol_table)) {
                        zend_rebuild_symbol_table(TSRMLS_C);
@@ -1288,7 +1290,7 @@
                RETURN_FALSE;
        }
                
-       for (i=1; i<num_args; i++) {
+       for (i=0; i<num_args; i++) {
                if (Z_TYPE_PP(args[i]) != IS_ARRAY && Z_TYPE_PP(args[i]) != 
IS_OBJECT) {
                        convert_to_string_ex(args[i]);
                }

http://cvs.php.net/viewvc.cgi/php-src/ext/wddx/tests/002.phpt?view=markup&rev=1.1
Index: php-src/ext/wddx/tests/002.phpt
+++ php-src/ext/wddx/tests/002.phpt
--TEST--
wddx packet construction using wddx ressource
--SKIPIF--
<?php if (!extension_loaded("wddx")) print "skip"; ?>
--INI--
precision=14
--FILE--
<?php
        $pkt = wddx_packet_start('TEST comment');

        $var1 = NULL;
        $var2 = 'some string';
        $var3 = 756;
        $var4 = true;

        // add vars to packet
        wddx_add_vars($pkt, 'var1', 'var2', array('var3', 'var4'));
        echo wddx_packet_end($pkt);
?>
--EXPECT--
<wddxPacket version='1.0'><header><comment>TEST 
comment</comment></header><data><struct><var name='var1'><null/></var><var 
name='var2'><string>some string</string></var><var 
name='var3'><number>756</number></var><var name='var4'><boolean 
value='true'/></var></struct></data></wddxPacket>

http://cvs.php.net/viewvc.cgi/php-src/ext/wddx/tests/003.phpt?view=markup&rev=1.1
Index: php-src/ext/wddx/tests/003.phpt
+++ php-src/ext/wddx/tests/003.phpt
--TEST--
wddx deserialize from ressource
--SKIPIF--
<?php if (!extension_loaded("wddx")) print "skip"; ?>
--INI--
precision=14
--FILE--
<?php
        $path = dirname(__FILE__);
        $fp = fopen("{$path}/wddx.xml", 'r');
        var_dump(wddx_deserialize($fp));
        fclose($fp);
?>
--EXPECT--
array(11) {
  ["aNull"]=>
  NULL
  ["aString"]=>
  string(8) "a string"
  ["aNumber"]=>
  float(-12.456)
  ["aDateTime"]=>
  int(897625932)
  ["aDateTime2"]=>
  int(329632332)
  ["aDateTime3"]=>
  int(2223088332)
  ["aBoolean"]=>
  bool(true)
  ["anArray"]=>
  array(2) {
    [0]=>
    int(10)
    [1]=>
    string(14) "second element"
  }
  ["aBinary"]=>
  string(11) "binary data"
  ["anObject"]=>
  array(2) {
    ["s"]=>
    string(8) "a string"
    ["n"]=>
    float(-12.456)
  }
  ["aRecordset"]=>
  array(2) {
    ["NAME"]=>
    array(2) {
      [0]=>
      string(8) "John Doe"
      [1]=>
      string(8) "Jane Doe"
    }
    ["AGE"]=>
    array(2) {
      [0]=>
      int(34)
      [1]=>
      int(31)
    }
  }
}

http://cvs.php.net/viewvc.cgi/php-src/ext/wddx/tests/004.phpt?view=markup&rev=1.1
Index: php-src/ext/wddx/tests/004.phpt
+++ php-src/ext/wddx/tests/004.phpt
--TEST--
wddx session serializer handler (serialize)
--SKIPIF--
<?php
        if (!extension_loaded("wddx")) die("skip Wddx module not loaded");
        if (!extension_loaded('session')) die('skip Session module not 
enabled');

        // following test code stolen from ext/session/skipif.inc
        $save_path = ini_get("session.save_path");
        if ($save_path) {
                if (!file_exists($save_path)) {
                        die("skip Session save_path doesn't exist");
                }

                if ($save_path && [EMAIL PROTECTED]($save_path)) {
                        if (($p = strpos($save_path, ';')) !== false) {
                                $save_path = substr($save_path, ++$p);
                        }
                        if ([EMAIL PROTECTED]($save_path)) {
                                die("skip\n");
                        }
                }
        }
?>
--INI--
precision=14
session.serialize_handler=wddx
session.use_cookies=0
session.cache_limiter=
session.save_handler=files
--FILE--
<?php
        class foo {
                public $bar = "ok";
                public $invisible = 'you don\'t see me!';

                function method() { $this->yes = "done"; }

                public function __sleep() { return array('bar', 'yes'); }
        }

        session_start();

        $_SESSION['data'] = array(
                'test1' => true,
                'test2' => 'some string',
                'test3' => 654321,
                'test4' => array(
                        'some string',
                        true,
                        null
                ),
        );

        $_SESSION['class'] = new foo();
        $_SESSION['class']->method();

        var_dump(session_encode());

        session_destroy();
?>
--EXPECT--
string(550) "<wddxPacket version='1.0'><header/><data><struct><var 
name='data'><struct><var name='test1'><boolean value='true'/></var><var 
name='test2'><string>some string</string></var><var 
name='test3'><number>654321</number></var><var name='test4'><array 
length='3'><string>some string</string><boolean 
value='true'/><null/></array></var></struct></var><var 
name='class'><struct><var name='php_class_name'><string>foo</string></var><var 
name='bar'><string>ok</string></var><var 
name='yes'><string>done</string></var></struct></var></struct></data></wddxPacket>"

http://cvs.php.net/viewvc.cgi/php-src/ext/wddx/tests/005.phpt?view=markup&rev=1.1
Index: php-src/ext/wddx/tests/005.phpt
+++ php-src/ext/wddx/tests/005.phpt
--TEST--
wddx session serializer handler (deserialize)
--SKIPIF--
<?php
        if (!extension_loaded("wddx")) die("skip Wddx module not loaded");
        if (!extension_loaded('session')) die('skip Session module not 
enabled');

        // following test code stolen from ext/session/skipif.inc
        $save_path = ini_get("session.save_path");
        if ($save_path) {
                if (!file_exists($save_path)) {
                        die("skip Session save_path doesn't exist");
                }

                if ($save_path && [EMAIL PROTECTED]($save_path)) {
                        if (($p = strpos($save_path, ';')) !== false) {
                                $save_path = substr($save_path, ++$p);
                        }
                        if ([EMAIL PROTECTED]($save_path)) {
                                die("skip\n");
                        }
                }
        }
?>
--INI--
precision=14
session.serialize_handler=wddx
session.use_cookies=0
session.cache_limiter=
session.save_handler=files
--FILE--
<?php
        class foo {
                public $bar = "ok";

                function method() { $this->yes = "done"; }
        }

        session_start();

        session_decode("<wddxPacket version='1.0'><header/><data><struct><var 
name='data'><struct><var name='test1'><boolean value='true'/></var><var 
name='test2'><string>some string</string></var><var 
name='test3'><number>654321</number></var><var name='test4'><array 
length='3'><string>some string</string><boolean 
value='true'/><null/></array></var></struct></var><var 
name='class'><struct><var name='php_class_name'><string>foo</string></var><var 
name='bar'><string>ok</string></var><var 
name='yes'><string>done</string></var></struct></var></struct></data></wddxPacket>");

        var_dump($_SESSION);

        session_destroy();
?>
--EXPECT--
array(2) {
  ["data"]=>
  array(4) {
    ["test1"]=>
    bool(true)
    ["test2"]=>
    string(11) "some string"
    ["test3"]=>
    int(654321)
    ["test4"]=>
    array(3) {
      [0]=>
      string(11) "some string"
      [1]=>
      bool(true)
      [2]=>
      NULL
    }
  }
  ["class"]=>
  object(foo)#1 (2) {
    ["bar"]=>
    string(2) "ok"
    ["yes"]=>
    string(4) "done"
  }
}

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

Reply via email to