Closed
Description
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:
if (is_null($xml->AmazonOrderId)){
$this->log("You just got throttled.",'Warning');
return false;
} else if (isset($this->options['AmazonOrderId']) && $this->options['AmazonOrderId'] && $this->options['AmazonOrderId'] != $xml->AmazonOrderId){
$this->log('You grabbed the wrong Order\'s items! - '.$this->options['AmazonOrderId'].' =/= '.$xml->AmazonOrderId,'Urgent');
return false;
}
/**
* Retrieves the items from Amazon.
*
* Submits a <i>ListOrderItems</i> request to Amazon. In order to do this,
* an Amazon order ID is required. Amazon will send
* the data back as a response, which can be retrieved using <i>getItems</i>.
* Other methods are available for fetching specific values from the order.
* This operation can potentially involve tokens.
* @param boolean <p>When set to <b>FALSE</b>, the function will not recurse, defaults to <b>TRUE</b></p>
* @return boolean <b>FALSE</b> if something goes wrong
*/
public function fetchItems($r = true){
$this->prepareToken();
$url = $this->urlbase.$this->urlbranch;
$query = $this->genQuery();
$path = $this->options['Action'].'Result';
if ($this->mockMode){
$xml = $this->fetchMockFile()->$path;
} else {
$response = $this->sendRequest($url, array('Post'=>$query));
if (!$this->checkResponse($response)){
return false;
}
$xml = simplexml_load_string($response['body'])->$path;
}
if (is_null($xml->AmazonOrderId)){
$this->log("You just got throttled.",'Warning');
return false;
} else if (isset($this->options['AmazonOrderId']) && $this->options['AmazonOrderId'] && $this->options['AmazonOrderId'] != $xml->AmazonOrderId){
$this->log('You grabbed the wrong Order\'s items! - '.$this->options['AmazonOrderId'].' =/= '.$xml->AmazonOrderId,'Urgent');
}
$this->parseXML($xml->OrderItems);
$this->checkToken($xml);
if ($this->tokenFlag && $this->tokenUseFlag && $r === true){
while ($this->tokenFlag){
$this->log("Recursively fetching more items");
$this->fetchItems(false);
}
}
}