Skip to content

Commit 1506ae4

Browse files
committed
MAGETWO-35076: Impossible to place order with DHL EU shipping method
- CR Changes
1 parent 46cf26b commit 1506ae4

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

app/code/Magento/Dhl/Model/Carrier.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ protected function _parseResponse($response)
10341034

10351035
if (strlen(trim($response)) > 0) {
10361036
if (strpos(trim($response), '<?xml') === 0) {
1037-
$xml = $this->parseXml($response);
1037+
$xml = $this->parseXml($response, 'Magento\Shipping\Model\Simplexml\Element');
10381038
if (is_object($xml)) {
10391039
if (in_array($xml->getName(), ['ErrorResponse', 'ShipmentValidateErrorResponse'])
10401040
|| isset($xml->GetQuoteResponse->Note->Condition)
@@ -1775,7 +1775,7 @@ protected function _parseXmlTrackingResponse($trackings, $response)
17751775
$resultArr = [];
17761776

17771777
if (strlen(trim($response)) > 0) {
1778-
$xml = $this->parseXml($response);
1778+
$xml = $this->parseXml($response, 'Magento\Shipping\Model\Simplexml\Element');
17791779
if (!is_object($xml)) {
17801780
$errorTitle = __('Response is in the wrong format');
17811781
}

app/code/Magento/Fedex/Model/Carrier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ protected function _parseXmlResponse($response)
706706
$priceArr = [];
707707

708708
if (strlen(trim($response)) > 0) {
709-
$xml = $this->parseXml($response);
709+
$xml = $this->parseXml($response, 'Magento\Shipping\Model\Simplexml\Element');
710710
if (is_object($xml)) {
711711
if (is_object($xml->Error) && is_object($xml->Error->Message)) {
712712
$errorTitle = (string)$xml->Error->Message;

app/code/Magento/Shipping/Model/Carrier/AbstractCarrierOnline.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,12 @@ public function getMethodPrice($cost, $method = '')
612612
* Parse XML string and return XML document object or false
613613
*
614614
* @param string $xmlContent
615-
* @return \Magento\Shipping\Model\Simplexml\Element|bool
615+
* @param string $customSimplexml
616+
*
617+
* @return \SimpleXMLElement|bool
616618
*/
617-
public function parseXml($xmlContent)
619+
public function parseXml($xmlContent, $customSimplexml = 'SimpleXMLElement')
618620
{
619-
return simplexml_load_string($xmlContent, 'Magento\Shipping\Model\Simplexml\Element');
621+
return simplexml_load_string($xmlContent, $customSimplexml);
620622
}
621623
}

app/code/Magento/Shipping/Test/Unit/Model/Carrier/AbstractCarrierOnlineTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@ public function testParseXml()
111111
$simpleXmlElement = $this->carrier->parseXml($xmlString);
112112
$this->assertEquals('GetResponse', $simpleXmlElement->getName());
113113
$this->assertEquals(42, (int)$simpleXmlElement->value);
114+
$this->assertInstanceOf('SimpleXMLElement', $simpleXmlElement);
115+
$customSimpleXmlElement = $this->carrier->parseXml($xmlString, 'Magento\Shipping\Model\Simplexml\Element');
116+
$this->assertInstanceOf('Magento\Shipping\Model\Simplexml\Element', $customSimpleXmlElement);
114117
}
115118
}

app/code/Magento/Usps/Model/Carrier.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ protected function _parseXmlResponse($response)
512512
$response
513513
);
514514
}
515-
$xml = $this->parseXml($response);
515+
$xml = $this->parseXml($response, 'Magento\Shipping\Model\Simplexml\Element');
516516

517517
if (is_object($xml)) {
518518
$allowedMethods = explode(',', $this->getConfigData('allowed_methods'));
@@ -1042,7 +1042,7 @@ protected function _parseXmlTrackingResponse($trackingvalue, $response)
10421042
$resultArr = [];
10431043
if (strlen(trim($response)) > 0) {
10441044
if (strpos(trim($response), '<?xml') === 0) {
1045-
$xml = $this->parseXml($response);
1045+
$xml = $this->parseXml($response, 'Magento\Shipping\Model\Simplexml\Element');
10461046
if (is_object($xml)) {
10471047
if (isset($xml->Number) && isset($xml->Description) && (string)$xml->Description != '') {
10481048
$errorTitle = (string)$xml->Description;
@@ -1869,7 +1869,7 @@ protected function _doShipmentRequest(\Magento\Framework\Object $request)
18691869
$client->setParameterGet('XML', $requestXml);
18701870
$response = $client->request()->getBody();
18711871

1872-
$response = $this->parseXml($response);
1872+
$response = $this->parseXml($response, 'Magento\Shipping\Model\Simplexml\Element');
18731873
if ($response === false || $response->getName() == 'Error') {
18741874
$debugData['result'] = [
18751875
'error' => $response->Description,

0 commit comments

Comments
 (0)