#19733 closed defect (bug) (fixed)
XML-RPC returns invalid dates if the date is zero
Reported by: | koke | Owned by: | westi |
---|---|---|---|
Milestone: | 3.4 | Priority: | normal |
Severity: | normal | Version: | 3.3 |
Component: | XML-RPC | Keywords: | has-patch mobile needs-unit-tests |
Focuses: | Cc: |
Description
When a post has a 'pending' status, post_date_gmt
is set to 0000-00-00 00:00:00
as a marker to update post_date
when it's saved (see #5698).
mysql2date then proceeds to turn that date into a negative one, and IXR_Date destroys the thing a bit more, so 0000-00-00 00:00:00
turns into -0001113TT0::0::00
, which is an invalid ISO8601 date
Attachments (8)
Change History (27)
#5
@
13 years ago
Also, IXR_Date doesn't like "weird" dates.
- mysql2date returns
-00011130T00:00:00
. It looks weird but it makes sense: 0000-00-00 -> -1-12-00 -> -1-11-30 - IXR_Date works by taking substrings, and the leading '-' is what breaks everything.
Using a NULL for a 'zero' date might make sense, but I wonder how many things would break, probably including XML-RPC :(
#6
@
13 years ago
- Cc marko@… added
Added a new patch at #18429 that also fixes this issue. Do need to test it tomorrow if it works as it should.
#8
@
13 years ago
Added a patch that applies the patch of maxcutler to all the methods. I didn't applied the code of the first patch of this ticket. Is that still needed?
#10
@
13 years ago
- Keywords needs-unit-tests added
I would really like to have the last patch in 3.4 but I also really don't want to commit it without us adding test cases because I just found a bunch of bugs in the featured image stuff we applied everywhere by writing the basic test cases for mw_(new|edit)_Post.
If someone wants to write up some tests to cover the date stuff that would be really helpful.
#11
@
13 years ago
I applied the patch of koke in a way that it only applies for incorrect dates. No matter what the post status is.
I also applied it to all the new XML-RPC methods so everything has the same date handling.
A benefit for this patch is that _convert_date and _convert_date_gmt only return an IXR_Date.
#12
@
13 years ago
I took a look at the last patch and all looks good apart from:
- _convert_mysql2date is a level of abstraction too far - lets just call mysql2date directly.
$this-> _convert_date( $date_gmt );
- space in this.
@markoheijnen could you give the patch a refresh to address these?
#14
@
13 years ago
- Owner set to westi
- Resolution set to fixed
- Status changed from new to closed
In [20353]:
@
11 years ago
Same unit tests as proposed before, but using a subclass rather than reflection to access the protected methods.
#15
@
11 years ago
The above two patches add two different approaches to testing _convert_date()
and _convert_date_gmt()
. The first patch uses reflection to gain access to the protected methods in the XMLRPC server class. The second patch creates a subclass to expose them publicly instead. Both work (and pass) and I leave it to the committer to chose the best approach.
Note: While the Reflection approach is cleaner in code, the subclass approach is easier for new devs to understand. I would recommend committing 19733.tests-subclass.diff.
#16
follow-up:
↓ 17
@
11 years ago
I personally would go for 19733.tests.diff. I think the reflection here is pretty easy to understand. It's a few lines of code and you did add a comment that you want to access a protected method.
I personally would split each test case by having a standard and a null test case.
#17
in reply to:
↑ 16
@
11 years ago
Replying to markoheijnen:
I personally would go for 19733.tests.diff. I think the reflection here is pretty easy to understand. It's a few lines of code and you did add a comment that you want to access a protected method.
Easy to understand, but somewhat non-standard. Hence the second patch as an alternative.
I personally would split each test case by having a standard and a null test case.
While we could split them out, there's no real added benefit of doing that. Plus having the standard and null date in the same test method doesn't really have a drawback. That said, if anyone else disagrees it would be trivial to split them.
Added a patch which sets the
post_date_gmt
value to the convertedpost_date
for pending and auto-draft posts.