Skip to content

Commit d7fe695

Browse files
committed
Merge branch '2.2-develop' of github.com:magento-mpi/magento2ce into MAGETWO-93497
2 parents c7f528b + f86e421 commit d7fe695

File tree

37 files changed

+996
-133
lines changed

37 files changed

+996
-133
lines changed

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/cc-form.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ define(
7979
*/
8080
onError: function (response) {
8181
braintree.showError($t('Payment ' + this.getTitle() + ' can\'t be initialized'));
82-
this.isPlaceOrderActionAllowed(true);
8382
throw response.message;
8483
},
8584

app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/hosted-fields.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ define([
156156
*/
157157
placeOrderClick: function () {
158158
if (this.validateCardType()) {
159-
this.isPlaceOrderActionAllowed(false);
160159
$(this.getSelector('submit')).trigger('click');
161160
}
162161
},

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Save.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -189,26 +189,6 @@ public function execute()
189189
? $model->getAttributeCode()
190190
: $this->getRequest()->getParam('attribute_code');
191191
$attributeCode = $attributeCode ?: $this->generateCode($this->getRequest()->getParam('frontend_label')[0]);
192-
if (strlen($attributeCode) > 0) {
193-
$validatorAttrCode = new \Zend_Validate_Regex(
194-
['pattern' => '/^[a-z\x{600}-\x{6FF}][a-z\x{600}-\x{6FF}_0-9]{0,30}$/u']
195-
);
196-
if (!$validatorAttrCode->isValid($attributeCode)) {
197-
$this->messageManager->addErrorMessage(
198-
__(
199-
'Attribute code "%1" is invalid. Please use only letters (a-z), ' .
200-
'numbers (0-9) or underscore(_) in this field, first character should be a letter.',
201-
$attributeCode
202-
)
203-
);
204-
205-
return $this->returnResult(
206-
'catalog/*/edit',
207-
['attribute_id' => $attributeId, '_current' => true],
208-
['error' => true]
209-
);
210-
}
211-
}
212192
$data['attribute_code'] = $attributeCode;
213193

214194
//validate frontend_input

app/code/Magento/Catalog/Pricing/Render/PriceBox.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Pricing\Render;
79

810
use Magento\Catalog\Model\Product;
@@ -71,7 +73,9 @@ public function jsonEncode($valueToEncode)
7173
*
7274
* @param int $length
7375
* @param string|null $chars
76+
*
7477
* @return string
78+
* @throws \Magento\Framework\Exception\LocalizedException
7579
*/
7680
public function getRandomString($length, $chars = null)
7781
{
@@ -93,4 +97,21 @@ public function getCanDisplayQty(Product $product)
9397
}
9498
return true;
9599
}
100+
101+
/**
102+
* Format percent
103+
*
104+
* @param float $percent
105+
*
106+
* @return string
107+
*/
108+
public function formatPercent(float $percent): string
109+
{
110+
/*First rtrim - trim zeros. So, 10.00 -> 10.*/
111+
/*Second rtrim - trim dot. So, 10. -> 10*/
112+
return rtrim(
113+
rtrim(number_format($percent, 2), '0'),
114+
'.'
115+
);
116+
}
96117
}

app/code/Magento/Catalog/view/base/templates/product/price/tier_prices.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ $product = $block->getSaleableItem();
7777
$price['price_qty'],
7878
$priceAmountBlock,
7979
$index,
80-
$tierPriceModel->getSavePercent($price['price'])
80+
$block->formatPercent($price['percentage_value'] ?? $tierPriceModel->getSavePercent($price['price']))
8181
)
8282
: __('Buy %1 for %2 each', $price['price_qty'], $priceAmountBlock);
8383
?>

app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,25 @@ define([
133133
event.preventDefault();
134134
}
135135

136-
if (this.validate() && additionalValidators.validate()) {
136+
if (this.validate() &&
137+
additionalValidators.validate() &&
138+
this.isPlaceOrderActionAllowed() === true
139+
) {
137140
this.isPlaceOrderActionAllowed(false);
138141

139142
this.getPlaceOrderDeferredObject()
140-
.fail(
141-
function () {
142-
self.isPlaceOrderActionAllowed(true);
143-
}
144-
).done(
143+
.done(
145144
function () {
146145
self.afterPlaceOrder();
147146

148147
if (self.redirectAfterPlaceOrder) {
149148
redirectOnSuccessAction.execute();
150149
}
151150
}
151+
).always(
152+
function () {
153+
self.isPlaceOrderActionAllowed(true);
154+
}
152155
);
153156

154157
return true;

app/code/Magento/Customer/Model/CustomerAuthUpdate.php

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,74 @@
66

77
namespace Magento\Customer\Model;
88

9+
use Magento\Customer\Model\ResourceModel\Customer as CustomerResourceModel;
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Exception\NoSuchEntityException;
12+
913
/**
1014
* Customer Authentication update model.
1115
*/
1216
class CustomerAuthUpdate
1317
{
1418
/**
15-
* @var \Magento\Customer\Model\CustomerRegistry
19+
* @var CustomerRegistry
1620
*/
1721
protected $customerRegistry;
1822

1923
/**
20-
* @var \Magento\Customer\Model\ResourceModel\Customer
24+
* @var CustomerResourceModel
2125
*/
2226
protected $customerResourceModel;
2327

2428
/**
25-
* @param \Magento\Customer\Model\CustomerRegistry $customerRegistry
26-
* @param \Magento\Customer\Model\ResourceModel\Customer $customerResourceModel
29+
* @var Customer
30+
*/
31+
private $customerModel;
32+
33+
/**
34+
* @param CustomerRegistry $customerRegistry
35+
* @param CustomerResourceModel $customerResourceModel
36+
* @param Customer|null $customerModel
2737
*/
2838
public function __construct(
29-
\Magento\Customer\Model\CustomerRegistry $customerRegistry,
30-
\Magento\Customer\Model\ResourceModel\Customer $customerResourceModel
39+
CustomerRegistry $customerRegistry,
40+
CustomerResourceModel $customerResourceModel,
41+
Customer $customerModel = null
3142
) {
3243
$this->customerRegistry = $customerRegistry;
3344
$this->customerResourceModel = $customerResourceModel;
45+
$this->customerModel = $customerModel ?: ObjectManager::getInstance()->get(Customer::class);
3446
}
3547

3648
/**
3749
* Reset Authentication data for customer.
3850
*
3951
* @param int $customerId
4052
* @return $this
53+
* @throws NoSuchEntityException
4154
*/
4255
public function saveAuth($customerId)
4356
{
4457
$customerSecure = $this->customerRegistry->retrieveSecureData($customerId);
4558

59+
$this->customerResourceModel->load($this->customerModel, $customerId);
60+
$currentLockExpiresVal = $this->customerModel->getData('lock_expires');
61+
$newLockExpiresVal = $customerSecure->getData('lock_expires');
62+
4663
$this->customerResourceModel->getConnection()->update(
4764
$this->customerResourceModel->getTable('customer_entity'),
4865
[
4966
'failures_num' => $customerSecure->getData('failures_num'),
5067
'first_failure' => $customerSecure->getData('first_failure'),
51-
'lock_expires' => $customerSecure->getData('lock_expires'),
68+
'lock_expires' => $newLockExpiresVal,
5269
],
5370
$this->customerResourceModel->getConnection()->quoteInto('entity_id = ?', $customerId)
5471
);
5572

73+
if ($currentLockExpiresVal !== $newLockExpiresVal) {
74+
$this->customerModel->reindex();
75+
}
76+
5677
return $this;
5778
}
5879
}

app/code/Magento/Customer/Test/Unit/Model/CustomerAuthUpdateTest.php

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@
55
*/
66
namespace Magento\Customer\Test\Unit\Model;
77

8+
use Magento\Customer\Model\Customer as CustomerModel;
89
use Magento\Customer\Model\CustomerAuthUpdate;
10+
use Magento\Customer\Model\CustomerRegistry;
11+
use Magento\Customer\Model\Data\CustomerSecure;
12+
use Magento\Customer\Model\ResourceModel\Customer as CustomerResourceModel;
13+
use Magento\Framework\DB\Adapter\AdapterInterface;
14+
use Magento\Framework\Exception\NoSuchEntityException;
15+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
916

1017
/**
1118
* Class CustomerAuthUpdateTest
@@ -18,17 +25,22 @@ class CustomerAuthUpdateTest extends \PHPUnit\Framework\TestCase
1825
protected $model;
1926

2027
/**
21-
* @var \Magento\Customer\Model\CustomerRegistry|\PHPUnit_Framework_MockObject_MockObject
28+
* @var CustomerRegistry|\PHPUnit_Framework_MockObject_MockObject
2229
*/
2330
protected $customerRegistry;
2431

2532
/**
26-
* @var \Magento\Customer\Model\ResourceModel\Customer|\PHPUnit_Framework_MockObject_MockObject
33+
* @var CustomerResourceModel|\PHPUnit_Framework_MockObject_MockObject
2734
*/
2835
protected $customerResourceModel;
2936

3037
/**
31-
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
38+
* @var CustomerModel|\PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
protected $customerModel;
41+
42+
/**
43+
* @var ObjectManager
3244
*/
3345
protected $objectManager;
3446

@@ -37,32 +49,36 @@ class CustomerAuthUpdateTest extends \PHPUnit\Framework\TestCase
3749
*/
3850
protected function setUp()
3951
{
40-
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
52+
$this->objectManager = new ObjectManager($this);
4153

4254
$this->customerRegistry =
43-
$this->createMock(\Magento\Customer\Model\CustomerRegistry::class);
55+
$this->createMock(CustomerRegistry::class);
4456
$this->customerResourceModel =
45-
$this->createMock(\Magento\Customer\Model\ResourceModel\Customer::class);
57+
$this->createMock(CustomerResourceModel::class);
58+
$this->customerModel =
59+
$this->createMock(CustomerModel::class);
4660

4761
$this->model = $this->objectManager->getObject(
48-
\Magento\Customer\Model\CustomerAuthUpdate::class,
62+
CustomerAuthUpdate::class,
4963
[
5064
'customerRegistry' => $this->customerRegistry,
5165
'customerResourceModel' => $this->customerResourceModel,
66+
'customerModel' => $this->customerModel
5267
]
5368
);
5469
}
5570

5671
/**
5772
* test SaveAuth
73+
* @throws NoSuchEntityException
5874
*/
5975
public function testSaveAuth()
6076
{
6177
$customerId = 1;
6278

63-
$customerSecureMock = $this->createMock(\Magento\Customer\Model\Data\CustomerSecure::class);
79+
$customerSecureMock = $this->createMock(CustomerSecure::class);
6480

65-
$dbAdapter = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
81+
$dbAdapter = $this->createMock(AdapterInterface::class);
6682

6783
$this->customerRegistry->expects($this->once())
6884
->method('retrieveSecureData')
@@ -98,6 +114,9 @@ public function testSaveAuth()
98114
$customerId
99115
);
100116

117+
$this->customerModel->expects($this->once())
118+
->method('reindex');
119+
101120
$this->model->saveAuth($customerId);
102121
}
103122
}

app/code/Magento/Eav/Model/Entity/Attribute.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -238,22 +238,6 @@ public function beforeSave()
238238
);
239239
}
240240

241-
/**
242-
* Check for maximum attribute_code length
243-
*/
244-
if (isset(
245-
$this->_data['attribute_code']
246-
) && !\Zend_Validate::is(
247-
$this->_data['attribute_code'],
248-
'StringLength',
249-
['max' => self::ATTRIBUTE_CODE_MAX_LENGTH]
250-
)
251-
) {
252-
throw new LocalizedException(
253-
__('An attribute code must not be more than %1 characters.', self::ATTRIBUTE_CODE_MAX_LENGTH)
254-
);
255-
}
256-
257241
$defaultValue = $this->getDefaultValue();
258242
$hasDefaultValue = (string)$defaultValue != '';
259243

0 commit comments

Comments
 (0)