Req #45187 [Opn->Wfx]: xmlrpc_encode_request should encode DateTime objects as datetime values
Edit report at https://bugs.php.net/bug.php?id=45187&edit=1
ID: 45187
Updated by: cmb@php.net
Reported by: pickscrape at gmail dot com
Summary: xmlrpc_encode_request should encode DateTime objects
as datetime values
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
Package: XMLRPC-EPI related
Operating System: Linux
PHP Version: 5.2.6
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
The xmlrpc extension is unbundled and moved to PECL as of PHP
7.4.0. I'm temporarily maintaining the extension, but I will not
do any feature additions. Actually, everybody is likely better
off to switch to something else. Thus, I'm closing this ticket.
Previous Comments:
------------------------------------------------------------------------
[2008-06-16 14:32:18] kawai at apache dot org
IMHO, this is not a bug but may be a feature request.
By the way, if we're going to support DateTime class object,
how do you think what the result of xmlrpc_decode_request
should be look like (keeping backword compatibility, of cource)?
------------------------------------------------------------------------
[2008-06-14 16:45:37] pickscrape at gmail dot com
Yes, that's kinda the point to this bug report.
When xmlrpc_encode_request walks the parameters array (recursively), any DateTime objects it
encounters should be encoded as XMLRPC datetime parameters (exactly like your snippet and the latter
half of my example demonstrate) transparently.
In other words, I'd expect the output from the first part of my script to be identical to the
output from the second.
------------------------------------------------------------------------
[2008-06-14 12:59:49] kawai at apache dot org
There is no statement that we can use DateTime object for
passing to an xmlrpc function, and actually, we can't use it.
It is a limitation of current implementation of xmlrpc extension.
However, I think we MAY support DateTime object in xmlrpc extension.
Current xmlrpc extension allows you to create xmlrpc datetime
value from an ISO-8601 format string. So you can code like this:
<?php
$obj=new DateTime();
$datetime=$obj->format(DATE_ISO8601);
xmlrpc_set_type($datetime,'datetime');
var_dump(xmlrpc_encode_request('x',$datetime));
?>
------------------------------------------------------------------------
[2008-06-12 17:50:28] pickscrape at gmail dot com
This script reproduces it. Interestingly, this script also causes a stack smash to happen for me on
Ubuntu, for which I have raised a separate bug (launchpad 239513). It runs fine under gentoo though
and reproduces this bug properly.
<?php
$params = array(new DateTime());
print_r($params);
echo "This is useless:\n";
print_r(xmlrpc_encode_request('x', $params));
echo "\nThis is what I would expect to happen automatically:\n";
$params2 = array(new DateTime());
$params2[0] = $params2[0]->format(DATE_ISO8601);
xmlrpc_set_type($params2[0], 'datetime');
print_r(xmlrpc_encode_request('x', $params2));
?>
------------------------------------------------------------------------
[2008-06-05 14:14:42] pickscrape at gmail dot com
Description:
------------
When encoding parameters to XML-RPC object of type DateTime should be converted into the standard
XMLRPC date format instead of the empty array that they are currently converted as.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=45187&edit=1
Thread (8 messages)