Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The php ISO8601 date format is not correct for XMLRPC dates #2885

Closed
wants to merge 7 commits into from

Conversation

mpcjanssen
Copy link
Contributor

Fix the issue that incorrect date format is used in XMLRPC responses (issue #2883).

Copy link
Collaborator

@splitbrain splitbrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good already but needs some polishing 👍

global $conf;
global $USERINFO;

parent::setUp();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're calling this twice. Here and in line 15.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed second instance.

_test/tests/inc/XmlRpcServer.test.php Outdated Show resolved Hide resolved
@@ -822,6 +826,8 @@ function getXml() {
*/
class IXR_Date {

const XMLRPC_ISO8601 = 'Ymd\TH:i:s';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This omits the timezone completely. That seems wrong to me.

According to https://www.php.net/manual/en/class.datetimeinterface.php#datetime.constants.iso8601 we could use DateTime:ATOM instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct. See http://xmlrpc.scripting.com/spec.html. The timezone that is used should be specified in the server documentation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Its weird. The spec example gives it without any time zone info, but at the same time calls it ISO8601. According to https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators there are different ways to represent the timezone, but it seems not to mention that it is optional.

Since the original problem in #2883 was your Java parser failing, could you check if it would work with DateTime:ATOM format? I would prefer having the timezone info intact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, some strange stuff here. Seems that this issue was actually already fixed in master (as compared to the Greebo version.

The ISO8601 format works with the Java parser it's the missing XML decoration in the Greebo version which is the issue. Sorry for the noise.

inc/Remote/XmlRpcServer.php Outdated Show resolved Hide resolved
@@ -406,7 +406,7 @@ function __construct($callbacks = false, $data = false, $wait = false) {
/**
* @param bool|string $data
*/
function serve($data = false) {
function serve($data = false, $test = false) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're using our own descendant of IXR_Server this could and should be implemented in our version dokuwiki\Remote\XmlRpcServer - or you could create your own child just for the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The IXR_Server implementation prints to stdout so I don't know how to wrap this in the child and capture the result.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overwrite the output function and use output buffering is probably the easiest way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commits below using a specific subclass for the test.

@mpcjanssen
Copy link
Contributor Author

I should probably create a new PR to only add the test class for XmlRpcServer to remove the commit noise.

@phy25
Copy link
Collaborator

phy25 commented Oct 16, 2019

I think it's OK if you have this many commits.

If you don't like too many commits, you can rearrange the branch and do a force-push, or reopen a PR... Whichever works for you are fine.

@mpcjanssen
Copy link
Contributor Author

@phy25 I am also fine with this as it shows the evolution of the PR, but not everyone agrees. Some projects value a "clean" timeline.

@mpcjanssen
Copy link
Contributor Author

My testing really needs some work: just tested again with master on my personal server and with current code state I get on my Java client:

Failed to parse server's response: Failed to parse date value 2019-10-15T09:10:21+0000 at position 4

@mpcjanssen
Copy link
Contributor Author

mpcjanssen commented Oct 16, 2019

Same error with DateTime::ATOM

@mpcjanssen
Copy link
Contributor Author

With const XMLRPC_ISO8601 = "Ymd\TH:i:sO" ; it works correctly in the Java XMLRPC client and keeps the timezone information.

@mpcjanssen
Copy link
Contributor Author

mpcjanssen commented Oct 16, 2019

I will create a new PR with the XmlRpcServer test class and the ISO date without -.

@mpcjanssen mpcjanssen closed this Oct 16, 2019
@mpcjanssen mpcjanssen mentioned this pull request Oct 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants