Problem/Motivation
I am working on a project that requires an external service which uses XML-RPC for requests. One API required date. It was not working. After debugging, I found that Drupal is not sending the date in xml request in correct format.
After digging I found that this xmlrpc_date_get_xml() is responsible for add a date in xml-rpc request. Also got some help from #321165-5: Exceptions for xmlrpc tests and date functions.
Looks like Drupal is missing an API which would format a date that can be used in xml-rpc request.
Proposed resolution
Write an API that would convert timestamp to a date format, that can be passed to xmlrpc_date_get_xml() which would add the date correctly in the xml-rpc request.
Remaining tasks
N/A
User interface changes
N/A
API changes
A new API that would convert timestamp to a date format, that can be passed to xmlrpc_date_get_xml() which would add the date correctly in the xml-rpc request.
Data model changes
N/A
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | interdiff-9-12.txt | 2.56 KB | subhojit777 |
| #11 | 2954303-11.patch | 3.03 KB | subhojit777 |
| #9 | 2954303-9.patch | 2.83 KB | subhojit777 |
| #9 | 2954303-5-9.txt | 2.01 KB | subhojit777 |
| #5 | 2954303-5.patch | 847 bytes | subhojit777 |
Comments
Comment #2
subhojit777Comment #4
subhojit777I don't know why the patch fails to apply. Alex Pott confirmed that it is applying with no errors for him.
Comment #5
subhojit777Comment #8
subhojit777Comment #9
subhojit777Comment #10
heddndate_dataprovider would be more in line of a name for a true PHP Unit test. Not sure if that means it is better, but I like it.
To make this more readable, perhaps add an additional level of 'actual' and 'expected' in this array. Actual would be the unix timestamp. Then year/month/etc. would be keyed under expected.
Comment #11
subhojit777Sounds good. Changes made.
Comment #12
heddnThis has great test coverage and adds an API function. So all that is missing is a change record for RTBC.
Comment #13
heddnComment #14
subhojit777Done. https://www.drupal.org/node/2956129
Comment #15
subhojit777Comment #16
heddnCan we show the before/after of what someone needed to do in the CR?
Comment #17
subhojit777I don't think so. The project I was working on, I was using the API, and the service kept throwing error, complaining that the data passed are incorrect. After debugging I found that Drupal was not passing the date in correct format, the datetime was not enclosed inside the
dateTime.iso8601xml tag in the request (seexmlrpc_date_get_xml()). And I figured the problem, and hence this API.Comment #18
subhojit777Sorry @heddn I misunderstood your request. I have updated the CR. Please check now.
Comment #19
subhojit777Comment #20
heddnLooking good. All feedback addressed.
Comment #21
pifagor commentedLooks good for me.
Comment #22
fgmSmall issue with the code itself.
REQUEST_TIME is deprecated since https://www.drupal.org/node/2785211 . This function may be invoked at a point where the container is not available, though, so some degree of explanation for the default value actually used needs to be added in the comments if there is no way to use the time service.
Also, the patch does not include any use case for this function in the module itself, so why is it needed at all ?
Beyond that, can you explain why this change is needed per the XML-RPC spec at http://xmlrpc.scripting.com/spec.html or a specific compatibility suite test ?