php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19628 WDDX should allow user to specify the variable type
Submitted: 2002-09-27 01:15 UTC Modified: 2002-10-03 04:04 UTC
From: jimmy at accellion dot com Assigned: jan (profile)
Status: Closed Package: WDDX related
PHP Version: 4.2.0 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jimmy at accellion dot com
New email:
PHP Version: OS:

 

 [2002-09-27 01:15 UTC] jimmy at accellion dot com
I am using PHP's WDDX and find it very useful, 
but that's only if I use it to exchange data 
between PHP program. Once I have to exchange
the data with other languange I begin to face 
problem after problem, mostly because of the 
way PHP's WDDX interpret the variable type.

The solution for this is, instead of 
auto-detecting the type of a var, PHP's WDDX 
should allow the user to explicitly specify 
the type they want the vars to be encoded as.

For example:

$string = "1";
wddx_serialize($string, WDDX_INTEGER);
// var $string will be encoded as integer, 
// instead of string

$file_name = "contain some unicode char";
wddx_serialize($file_name, WDDX_BINARY);
// var $file_name will be encoded 
// as binary, instead of string


Two good reasons why this should be implemented:

1. The main purpose of WDDX is to exchange data 
   between diff lang, and auto-detecting var type 
   will break this purpose.  Moreover, the
   type-juggling in PHP will make the case worst.

   For example, consider these two data:

     array ("2" => "Two", "4" => "Four", "5" => "Five");
     array ("0" => "Zero", "1" => "One", "2" => "Two");

   The first one will be interpreted by WDDX as hash 
   (assoc array).  But the second one, where the key 
   happen to be a sequence starting from 0, will be 
   interpreted as normal array, not hash.

2. If users can specify the type of a variable, 
   then PHP's WDDX can support all type which 
   is defined in WDDX standard.
   For example binary type. Currently there's no way 
   to create a WDDX packet with binary type, because 
   PHP don't have binary type variable.  There's a
   workaround to manually base64 the var, but this
   will require a change at the other end to handle 
   this workaround too, which in some cases is 
   not possible.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-27 01:20 UTC] jan@php.net
assign
 [2002-10-03 04:04 UTC] jan@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

we have wddx_serialize_type now
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 17:01:29 2024 UTC