php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44996 [PATCH] xmlrpc_decode() ignores time zone on iso8601.datetime
Submitted: 2008-05-14 17:47 UTC Modified: 2009-05-13 14:26 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: helixpip at gmail dot com Assigned:
Status: Closed Package: XMLRPC-EPI related
PHP Version: 5.*, 6CVS (2009-01-21) OS: *
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: helixpip at gmail dot com
New email:
PHP Version: OS:

 

 [2008-05-14 17:47 UTC] helixpip at gmail dot com
Description:
------------
The xmlrpc_decode function does not correctly interpret ISO 8601 timezone designations when interpreting XML-RPC datetime values passed in <dateTime.iso8601> tags.  It appears that the time zone designator is completely ignored and the local time zone is assumed.  (The xmlrpc_decode_request function shows the same behavior.)

A side effect of this bug is that the 'scalar' and 'timestamp' objects returned for XML-RPC datetime values will disagree if the object is used is used in a different time zone than it was created.  Ideally the scalar property should explicitly be a UTC ISO 8601 datetime value, ending with the time zone designator 'Z'.

Reproduce code:
---------------
function DecodeDatetime($datetime) {
  print "\nISO 8601 datetime $datetime\n";
  print "strtotime yields " . strtotime($datetime) . "\nxmlrpc_decode yields ";
  $obj = xmlrpc_decode("<?xml version=\"1.0\"?><methodResponse><params><param><value><dateTime.iso8601>$datetime</dateTime.iso8601></value></param></params></methodResponse>");
  print_r($obj);
}

DecodeDatetime("20010909T01:46:40Z");
DecodeDatetime("20010909T00:46:40-01");
DecodeDatetime("2001-09-09T08:46:40+07:00");
DecodeDatetime("2001-09-08T21:46:40-0400");

Expected result:
----------------
The ISO 8601 datetime strings tested above are all valid and equivalent   They all represent the same timestamp as the unix time 1000000000, and strtotime() function converts them all correctly.  I would expect that the object returned by xml_rpc decode should, in all four test cases, have the timestamp property = 1000000000 and have the scalar property as a string that would convert to 1000000000 if fed to strtotime().

Actual result:
--------------
The xmlrpc_decode function gets them all wrong except for the last one, which happens to have the same time zone as my test system:

ISO 8601 datetime 20010909T01:46:40Z
strtotime yields 1000000000
xmlrpc_decode yields stdClass Object
(
    [scalar] => 20010909T01:46:40
    [xmlrpc_type] => datetime
    [timestamp] => 1000014400
)

ISO 8601 datetime 20010909T00:46:40-01
strtotime yields 1000000000
xmlrpc_decode yields stdClass Object
(
    [scalar] => 20010909T00:46:40
    [xmlrpc_type] => datetime
    [timestamp] => 1000010800
)

ISO 8601 datetime 2001-09-09T08:46:40+07:00
strtotime yields 1000000000
xmlrpc_decode yields stdClass Object
(
    [scalar] => 20010909T08:46:40
    [xmlrpc_type] => datetime
    [timestamp] => 1000039600
)

ISO 8601 datetime 2001-09-08T21:46:40-0400
strtotime yields 1000000000
xmlrpc_decode yields stdClass Object
(
    [scalar] => 20010908T21:46:40
    [xmlrpc_type] => datetime
    [timestamp] => 1000000000
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-05-14 18:14 UTC] helixpip at gmail dot com
I wrote:
>Ideally the scalar property should explicitly be 
>a UTC ISO 8601 datetime value, ending with the 
>time zone designator 'Z'.

On second thought, it might be more useful for a php script to know what, if any, time zone designator appeared with the original iso8601 datetime value. (At the moment there's no way to find this information without parsing the xml.) If the scalar property preserved the original time zone designator, that would help with this.
 [2008-06-05 05:28 UTC] kawai at apache dot org
Now, you can download patched version of xmlrpc extension from:
http://mp.i-revo.jp/user.php/kcvcrlkq/entry/313.html

I hope this patch to be applied in the next PHP release.
 [2008-12-05 17:01 UTC] helixpip at gmail dot com
Just tested with 5.2.7.  The behavior has changed, but it's still not working correctly.  The 'scalar' property now returns the original text of the string passed in the <dateTime.iso8601> tags, which is good.  The conversion of this string to a timestamp that is stored in the 'timestamp' property still appears to be ignoring the timezone designator, however.  Previously, it ignored the timezone designator and assumed local time.  Now, it appears to ignore the timezone designator and assume Zulu time.  Strtotime() still gives the correct timestamp in all cases.  Results of tests:

ISO 8601 datetime 20010909T01:46:40Z
strtotime yields 1000000000
xmlrpc_decode
yields stdClass Object
(
    [scalar] => 20010909T01:46:40Z
    [xmlrpc_type] => datetime
    [timestamp] => 1000000000
)

ISO 8601 datetime 20010909T00:46:40-01
strtotime yields 1000000000
xmlrpc_decode
yields stdClass Object
(
    [scalar] => 20010909T00:46:40-01
    [xmlrpc_type] => datetime
    [timestamp] => 999996400
)

ISO 8601 datetime 2001-09-09T08:46:40+07:00
strtotime yields 1000000000
xmlrpc_decode
yields stdClass Object
(
    [scalar] => 2001-09-09T08:46:40+07:00
    [xmlrpc_type] => datetime
    [timestamp] => 1000025200
)

ISO 8601 datetime 2001-09-08T21:46:40-0400
strtotime yields 1000000000
xmlrpc_decode
yields stdClass Object
(
    [scalar] => 2001-09-08T21:46:40-0400
    [xmlrpc_type] => datetime
    [timestamp] => 999985600
)
 [2009-01-09 10:00 UTC] kawai at apache dot org
Following is a patch for timezone problem.

The patch will fix the bug even if xmlrpc-epi did not parse timezone 
correctly. xmlrpc-epi should be patched as 
http://sourceforge.net/tracker2/?
func=detail&aid=2495315&group_id=23199&atid=377730.
----------------------------
--- ext/xmlrpc/xmlrpc-epi-php.c.orig	2008-07-19 02:34:07.000000000 
+0900
+++ ext/xmlrpc/xmlrpc-epi-php.c	2009-01-10 03:39:19.000000000 +0900
@@ -1300,7 +1300,7 @@
 			if(newtype == xmlrpc_datetime) {
 				XMLRPC_VALUE v = 
XMLRPC_CreateValueDateTime_ISO8601(NULL, value->value.str.val);
 				if(v) {
-					time_t timestamp = 
XMLRPC_GetValueDateTime(v);
+					time_t timestamp = 
(time_t)php_parse_date(XMLRPC_GetValueDateTime_ISO8601(v), NULL);
 					if(timestamp) {
 						zval* ztimestamp;
 [2009-05-13 14:26 UTC] iliaa@php.net
This bug has been fixed in CVS.

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/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 18:01:31 2024 UTC