WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 8 years ago

#1528 closed defect (bug) (duplicate)

Error when submitting newPost using XMLRPC due to incompatible date formatting

Reported by: chazegh Owned by:
Milestone: Priority: normal
Severity: normal Version: 1.5.2
Component: XML-RPC Keywords:
Focuses: Cc:

Description

I get the following error when I try to submit a new post using the PHPXMLRPC library (http://phpxmlrpc.sourceforge.net/). I can make the problem go away by not submitting a date, but that shouldn't be a problem. The error is as follows:

Fatal error</b>: Call to a member function on a non-object in <b>..../site/xmlrpc.php</b> on line <b>549</b>

I solved the problem by making the following changes.

547: $dateCreatedd = $content_structdateCreated?;


547: $dateCreatedd = new IXR_Date($content_structdateCreated?);

642: $dateCreatedd = $content_structdateCreated?;


642: $dateCreatedd = new IXR_Date($content_structdateCreated?);

Apologies for the nonstandard diff format.

Also, this bug applies to 1.5.1.3, not 1.5.1.2 as the metadata for this report suggests. 1.5.1.3 is not an option currently.

Change History (8)

comment:1 @chazegh10 years ago

I should also add that the time it gives me is GMT-14. I have my GMT offset set for GMT-7, so the date is being offset twice.

comment:2 @westi10 years ago

chazegh: This sounds to me like one of the XML-RPC issues that has possibly been fixed in the 1.5 branch post 1.5.1.3 release.

It might be worth testing against this newer code to see if it fixes these issues for you.

comment:3 @markjaquith10 years ago

Actually... the lines that chazegh references have not been changed in /branches/1.5/ or /trunk/

comment:4 follow-up: @Omegas9 years ago

  • Version changed from 1.5.1.2 to 1.5.2

I can confirm that this issue is still present in 1.5.2. Posting through the XML-RPC interface works as long as you don't provide a dateCreated key with the post. The solution presented by chazegh works but isn't very robust since the IXR_Date class constructor is very strict when parsing the date string and the same applies to WP's own iso_8601 functions. The format coming from an XML-RPC client must be exactly YYYYMMDDThh:mm:ss[+-]ZZZZ or everything breaks... I've seen lots of software using YYYY-MM-DDThh:mm:ss[+-]ZZ:ZZ format as "ISO-8601" so I really think WP should be more relaxed when them. Adding conditional '-'s and ':'s in the regexps isn't really that hard after all...

comment:5 @rob1n8 years ago

  • Keywords xmlrpc datecreated removed

Still there for 2.1?

comment:6 in reply to: ↑ 4 @westi8 years ago

  • Milestone set to 2.2

Replying to Omegas:

I can confirm that this issue is still present in 1.5.2. Posting through the XML-RPC interface works as long as you don't provide a dateCreated key with the post. The solution presented by chazegh works but isn't very robust since the IXR_Date class constructor is very strict when parsing the date string and the same applies to WP's own iso_8601 functions. The format coming from an XML-RPC client must be exactly YYYYMMDDThh:mm:ss[+-]ZZZZ or everything breaks... I've seen lots of software using YYYY-MM-DDThh:mm:ss[+-]ZZ:ZZ format as "ISO-8601" so I really think WP should be more relaxed when them. Adding conditional '-'s and ':'s in the regexps isn't really that hard after all...

This sounds like a reasonable change. As far as I remember the -'s and :'s are optional in iso8601 so the date is valid with and without them.

The example in the 'spec' has no -'s but does have the :'s confusingly - 19980717T14:08:55

comment:7 @foolswisdom8 years ago

  • Milestone changed from 2.2 to 2.3

comment:8 @westi8 years ago

  • Milestone 2.3 deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Summary changed from Error when submitting newPost using PHPXMLRPC to Error when submitting newPost using XMLRPC due to incompatible date formatting

Closing as a duplicate of #3995 which has a patch as this is the same issue effectively

Note: See TracTickets for help on using tickets.