listOrderItems response invalid when GiftMessageText present


#1

I’m currently receiving invalid XML on hundreds of accounts when an orderItem contains GiftMessageText. The XML is just truncated after the first line of GiveMessageText.

From what I can tell this started about 9am PST on Monday, Feb 16th.

MWS Ticket submitted with a specific example. I have plenty more available if needed.


#2

Correction, it seems to be just the PHP Client library that is having the problem. The XML contains this:

    <promotiondiscount>
      <amount>0.00</amount>
      <currencycode>USD</currencycode>
    </promotiondiscount>
    <giftmessagetext>Happy Birthday, Ned

From: Dad
B012345678
1

This appears to affect both the 2014-10-20 and 2015-02-13 versions of the PHP library.

The problem is the PHP library is using preg_split without the optional 3rd argument as a limit to the number of items to split. The two newlines here is causing the PHP library to truncate the body text after the first line of the GiftMessageText, making the XML invalid.

The fix is to change line 687 from
$responseComponents = preg_split("/(?:\r?\n){2}/", $response);

to
$responseComponents = preg_split("/(?:\r?\n){2}/", $response, 2);

(Note: just add the third argument of ‘2’ to make it only split into a maximum of two parts.

Edited by: RoundSphere, LLC on Feb 18, 2015 2:44 PM


#3

FYI, more detail and example posted at http://sellerlabs.com/fixing-amazons-mws-client-libraries/


#4

Glad to see that the latest version of the Orders API PHP Library (Version: 2015-04-30) includes this fix.


closed #5