{"action":"created","issue":{"url":"https://api.github.com/repos/CPIGroup/phpAmazonMWS/issues/45","labels_url":"https://api.github.com/repos/CPIGroup/phpAmazonMWS/issues/45/labels{/name}","comments_url":"https://api.github.com/repos/CPIGroup/phpAmazonMWS/issues/45/comments","events_url":"https://api.github.com/repos/CPIGroup/phpAmazonMWS/issues/45/events","html_url":"https://github.com/CPIGroup/phpAmazonMWS/issues/45","id":75634070,"number":45,"title":"AmazonOrderItemList returns non-matching AmazonOrderItem for AmazonOrder","user":{"login":"HMAZonderland","id":4153366,"avatar_url":"https://avatars.githubusercontent.com/u/4153366?v=3","gravatar_id":"","url":"https://api.github.com/users/HMAZonderland","html_url":"https://github.com/HMAZonderland","followers_url":"https://api.github.com/users/HMAZonderland/followers","following_url":"https://api.github.com/users/HMAZonderland/following{/other_user}","gists_url":"https://api.github.com/users/HMAZonderland/gists{/gist_id}","starred_url":"https://api.github.com/users/HMAZonderland/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HMAZonderland/subscriptions","organizations_url":"https://api.github.com/users/HMAZonderland/orgs","repos_url":"https://api.github.com/users/HMAZonderland/repos","events_url":"https://api.github.com/users/HMAZonderland/events{/privacy}","received_events_url":"https://api.github.com/users/HMAZonderland/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-05-12T15:07:56Z","updated_at":"2015-05-12T16:26:57Z","closed_at":null,"body":"I've been debugging this application further. If you take a closer look to the `else if` statement you'll see it will add a Log entry when the AmazonOrderId's do not match. But it allows the code to continue. The code will continue to parse and return the Items for the wrong Order object. Perhaps you should add a `return false;` there:\r\n\r\n```php\r\nif (is_null($xml->AmazonOrderId)){\r\n    $this->log(\"You just got throttled.\",'Warning');\r\n    return false;\r\n} else if (isset($this->options['AmazonOrderId']) && $this->options['AmazonOrderId'] && $this->options['AmazonOrderId'] != $xml->AmazonOrderId){\r\n    $this->log('You grabbed the wrong Order\\'s items! - '.$this->options['AmazonOrderId'].' =/= '.$xml->AmazonOrderId,'Urgent');\r\n    return false;\r\n}\r\n```\r\n\r\n```php\r\n/**\r\n * Retrieves the items from Amazon.\r\n * \r\n * Submits a <i>ListOrderItems</i> request to Amazon. In order to do this,\r\n * an Amazon order ID is required. Amazon will send\r\n * the data back as a response, which can be retrieved using <i>getItems</i>.\r\n * Other methods are available for fetching specific values from the order.\r\n * This operation can potentially involve tokens.\r\n * @param boolean <p>When set to <b>FALSE</b>, the function will not recurse, defaults to <b>TRUE</b></p>\r\n * @return boolean <b>FALSE</b> if something goes wrong\r\n */\r\npublic function fetchItems($r = true){\r\n    $this->prepareToken();\r\n    \r\n    $url = $this->urlbase.$this->urlbranch;\r\n    \r\n    $query = $this->genQuery();\r\n    \r\n    $path = $this->options['Action'].'Result';\r\n    if ($this->mockMode){\r\n       $xml = $this->fetchMockFile()->$path;\r\n    } else {\r\n        $response = $this->sendRequest($url, array('Post'=>$query));\r\n        \r\n        if (!$this->checkResponse($response)){\r\n            return false;\r\n        }\r\n        \r\n        $xml = simplexml_load_string($response['body'])->$path;\r\n    }\r\n    \r\n    if (is_null($xml->AmazonOrderId)){\r\n        $this->log(\"You just got throttled.\",'Warning');\r\n        return false;\r\n    } else if (isset($this->options['AmazonOrderId']) && $this->options['AmazonOrderId'] && $this->options['AmazonOrderId'] != $xml->AmazonOrderId){\r\n        $this->log('You grabbed the wrong Order\\'s items! - '.$this->options['AmazonOrderId'].' =/= '.$xml->AmazonOrderId,'Urgent');\r\n    }\r\n    \r\n    $this->parseXML($xml->OrderItems);\r\n    \r\n    $this->checkToken($xml);\r\n    \r\n    if ($this->tokenFlag && $this->tokenUseFlag && $r === true){\r\n        while ($this->tokenFlag){\r\n            $this->log(\"Recursively fetching more items\");\r\n            $this->fetchItems(false);\r\n        }\r\n    }\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/CPIGroup/phpAmazonMWS/issues/comments/101339418","html_url":"https://github.com/CPIGroup/phpAmazonMWS/issues/45#issuecomment-101339418","issue_url":"https://api.github.com/repos/CPIGroup/phpAmazonMWS/issues/45","id":101339418,"user":{"login":"Peardian","id":2624085,"avatar_url":"https://avatars.githubusercontent.com/u/2624085?v=3","gravatar_id":"","url":"https://api.github.com/users/Peardian","html_url":"https://github.com/Peardian","followers_url":"https://api.github.com/users/Peardian/followers","following_url":"https://api.github.com/users/Peardian/following{/other_user}","gists_url":"https://api.github.com/users/Peardian/gists{/gist_id}","starred_url":"https://api.github.com/users/Peardian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Peardian/subscriptions","organizations_url":"https://api.github.com/users/Peardian/orgs","repos_url":"https://api.github.com/users/Peardian/repos","events_url":"https://api.github.com/users/Peardian/events{/privacy}","received_events_url":"https://api.github.com/users/Peardian/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T16:26:57Z","updated_at":"2015-05-12T16:26:57Z","body":"Now that I look at it again, it seems there isn't one. That would be a useful thing to have, but I can't do anything about it at this time."}}