php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #45187 xmlrpc_encode_request should encode DateTime objects as datetime values
Submitted: 2008-06-05 14:14 UTC Modified: 2021-04-13 13:53 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: pickscrape at gmail dot com Assigned: cmb (profile)
Status: Wont fix Package: XMLRPC-EPI related
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID: None
 [2008-06-05 14:14 UTC] 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.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-12 17:50 UTC] 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-14 12:59 UTC] 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-14 16:45 UTC] 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-16 14:32 UTC] 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)?
 [2011-01-23 21:33 UTC] jani@php.net
-Package: Feature/Change Request +Package: XMLRPC-EPI related
 [2021-04-13 13:53 UTC] cmb@php.net
-Status: Open +Status: Wont fix -Assigned To: +Assigned To: cmb
 [2021-04-13 13:53 UTC] cmb@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Oct 15 04:01:26 2024 UTC