Skip to content

Commit 6b486f7

Browse files
authored
Merge pull request #641 from magento-south/BUGS-2.0
[South] Bugs 2.0: - MAGETWO-61178 Inconsistent sales_order_item information after upgrade - MAGETWO-61232 Shipping rates can not be loaded - MAGETWO-61249 [Backport] Loader doesn't disappear after click on 'Place Order' button - for 2.0
2 parents 29c17ce + c7a5c70 commit 6b486f7

File tree

10 files changed

+62
-23
lines changed

10 files changed

+62
-23
lines changed

app/code/Magento/Authorizenet/Controller/Directpost/Payment/Place.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected function placeCheckoutOrder()
127127
);
128128
} catch (\Exception $exception) {
129129
$result->setData('error', true);
130-
$result->setData('error_messages', __('Cannot place order.'));
130+
$result->setData('error_messages', __('Unable to place order. Please try again later.'));
131131
}
132132
if ($response instanceof Http) {
133133
$response->representJson($this->jsonHelper->jsonEncode($result));

app/code/Magento/Authorizenet/Test/Unit/Controller/Directpost/Payment/PlaceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ public function textExecuteFailedPlaceOrderDataProvider()
279279
{
280280
$objectFailed = new \Magento\Framework\DataObject();
281281
$objectFailed->setData('error', true);
282-
$objectFailed->setData('error_messages', __('Cannot place order.'));
282+
$objectFailed->setData('error_messages', __('Unable to place order. Please try again later.'));
283283

284284
return [
285285
[

app/code/Magento/Authorizenet/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Cancel,Cancel
1313
"Something went wrong canceling the transactions.","Something went wrong canceling the transactions."
1414
"There was an error canceling transactions. Please contact us or try again later.","There was an error canceling transactions. Please contact us or try again later."
1515
"We couldn't process your order right now. Please try again later.","We couldn't process your order right now. Please try again later."
16+
"Unable to place order. Please try again later.","Unable to place order. Please try again later."
1617
"amount %1","amount %1"
1718
failed,failed
1819
successful,successful

app/code/Magento/Customer/Model/Address/AbstractAddress.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public function setData($key, $value = null)
263263
{
264264
if (is_array($key)) {
265265
$key = $this->_implodeArrayField($key);
266-
} elseif (is_array($value) && !empty($value) && $this->isAddressMultilineAttribute($key)) {
266+
} elseif (is_array($value) && $this->isAddressMultilineAttribute($key)) {
267267
$value = $this->_implodeArrayValues($value);
268268
}
269269
return parent::setData($key, $value);
@@ -291,7 +291,7 @@ protected function isAddressMultilineAttribute($code)
291291
protected function _implodeArrayField(array $data)
292292
{
293293
foreach ($data as $key => $value) {
294-
if (is_array($value) && !empty($value) && $this->isAddressMultilineAttribute($key)) {
294+
if (is_array($value) && $this->isAddressMultilineAttribute($key)) {
295295
$data[$key] = $this->_implodeArrayValues($data[$key]);
296296
}
297297
}
@@ -301,22 +301,24 @@ protected function _implodeArrayField(array $data)
301301
/**
302302
* Combine values of field lines into a single string
303303
*
304-
* @param string[]|string $value
304+
* @param array $value
305305
* @return string
306306
*/
307307
protected function _implodeArrayValues($value)
308308
{
309-
if (is_array($value) && count($value)) {
310-
$isScalar = false;
309+
if (is_array($value)) {
310+
$isScalar = true;
311311
foreach ($value as $val) {
312-
if (is_scalar($val)) {
313-
$isScalar = true;
312+
if (!is_scalar($val)) {
313+
$isScalar = false;
314314
}
315315
}
316+
316317
if ($isScalar) {
317318
$value = trim(implode("\n", $value));
318319
}
319320
}
321+
320322
return $value;
321323
}
322324

app/code/Magento/Paypal/view/frontend/web/js/view/payment/method-renderer/payflowpro-method.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,24 @@ define(
5252
var self = this;
5353

5454
if (this.validateHandler() && additionalValidators.validate()) {
55-
fullScreenLoader.startLoader();
5655
this.isPlaceOrderActionAllowed(false);
57-
$.when(setPaymentInformationAction(this.messageContainer, {
58-
'method': self.getCode()
59-
})).done(function () {
60-
self.placeOrderHandler().fail(function () {
56+
fullScreenLoader.startLoader();
57+
$.when(
58+
setPaymentInformationAction(this.messageContainer, {'method': self.getCode()})
59+
).done(
60+
function () {
61+
self.placeOrderHandler().fail(
62+
function () {
63+
fullScreenLoader.stopLoader();
64+
}
65+
);
66+
}
67+
).always(
68+
function () {
69+
self.isPlaceOrderActionAllowed(true);
6170
fullScreenLoader.stopLoader();
62-
});
63-
}).fail(function () {
64-
fullScreenLoader.stopLoader();
65-
self.isPlaceOrderActionAllowed(true);
66-
});
71+
}
72+
);
6773
}
6874
}
6975
});

app/code/Magento/Quote/Model/QuoteManagement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
354354
$order = $this->submit($quote);
355355

356356
if (null == $order) {
357-
throw new LocalizedException(__('Cannot place order.'));
357+
throw new LocalizedException(__('Unable to place order. Please try again later.'));
358358
}
359359

360360
$this->checkoutSession->setLastQuoteId($quote->getId());

app/code/Magento/Quote/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ Shipping,Shipping
2929
"Please specify a shipping method.","Please specify a shipping method."
3030
"Please check the billing address information. %1","Please check the billing address information. %1"
3131
"Please select a valid payment method.","Please select a valid payment method."
32+
"Unable to place order. Please try again later.","Unable to place order. Please try again later."

app/code/Magento/Sales/Model/ResourceModel/Order/Item/Collection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ protected function _afterLoad()
5555
* Assign parent items
5656
*/
5757
foreach ($this as $item) {
58-
$this->_resource->unserializeFields($item);
5958
if ($item->getParentItemId()) {
6059
$item->setParentItem($this->getItemById($item->getParentItemId()));
6160
}

lib/internal/Magento/Framework/Model/ResourceModel/Db/Collection/AbstractCollection.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,13 @@ protected function _afterLoad()
571571
parent::_afterLoad();
572572
foreach ($this->_items as $item) {
573573
$item->setOrigData();
574-
if ($this->_resetItemsDataChanged && ($item instanceof \Magento\Framework\Model\AbstractModel)) {
575-
$item->setDataChanges(false);
574+
575+
if ($item instanceof \Magento\Framework\Model\AbstractModel) {
576+
$this->getResource()->unserializeFields($item);
577+
578+
if ($this->_resetItemsDataChanged) {
579+
$item->setDataChanges(false);
580+
}
576581
}
577582
}
578583
$this->_eventManager->dispatch('core_collection_abstract_load_after', ['collection' => $this]);

lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/Db/Collection/AbstractCollectionTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Magento\Framework\Model\Test\Unit\ResourceModel\Db\Collection;
1010

1111
use Magento\Framework\DB\Select;
12+
use Magento\Framework\Model\AbstractModel;
1213
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
1314
use Magento\Framework\DataObject as MagentoObject;
1415
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
@@ -257,6 +258,30 @@ public function addFieldToSelectDataProvider()
257258
];
258259
}
259260

261+
public function testLoadWithItemFieldsUnserialization()
262+
{
263+
$itemMock = $this->getMockBuilder(AbstractModel::class)
264+
->disableOriginalConstructor()
265+
->getMock();
266+
$this->uut->addItem($itemMock);
267+
268+
$itemMock->expects($this->once())
269+
->method('setOrigData');
270+
$this->resourceMock->expects($this->once())
271+
->method('unserializeFields')
272+
->with($itemMock);
273+
274+
$this->managerMock->expects($this->exactly(2))
275+
->method('dispatch')
276+
->withConsecutive(
277+
['core_collection_abstract_load_before', ['collection' => $this->uut]],
278+
['core_collection_abstract_load_after', ['collection' => $this->uut]]
279+
280+
);
281+
282+
$this->uut->load();
283+
}
284+
260285
/**
261286
* @dataProvider addExpressionFieldToSelectDataProvider
262287
*/

0 commit comments

Comments
 (0)