Skip to content

Commit 7ec352a

Browse files
Merge pull request #1639 from magento-engcom/develop-prs
[EngCom] Public Pull Requests - develop - MAGETWO-82942: Send email to subscribers only when are new #11604 - MAGETWO-82752: Fixes translations by re-running the loadData for its correct locale #10913 - MAGETWO-82460: Fix AcountManagementTest unit test fail randomly #11605 - MAGETWO-82070: Update knockout #11269
2 parents 840d914 + b01eeb0 commit 7ec352a

File tree

9 files changed

+1064
-537
lines changed

9 files changed

+1064
-537
lines changed

app/code/Magento/Checkout/view/frontend/web/js/model/step-navigator.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ define([
4545
return false;
4646
}
4747

48-
steps.sort(this.sortItems).forEach(function (element) {
48+
steps().sort(this.sortItems).forEach(function (element) {
4949
if (element.code == hashString || element.alias == hashString) { //eslint-disable-line eqeqeq
5050
element.navigate(element);
5151
} else {
@@ -111,7 +111,7 @@ define([
111111
getActiveItemIndex: function () {
112112
var activeIndex = 0;
113113

114-
steps.sort(this.sortItems).forEach(function (element, index) {
114+
steps().sort(this.sortItems).forEach(function (element, index) {
115115
if (element.isVisible()) {
116116
activeIndex = index;
117117
}
@@ -126,7 +126,7 @@ define([
126126
*/
127127
isProcessed: function (code) {
128128
var activeItemIndex = this.getActiveItemIndex(),
129-
sortedItems = steps.sort(this.sortItems),
129+
sortedItems = steps().sort(this.sortItems),
130130
requestedItemIndex = -1;
131131

132132
sortedItems.forEach(function (element, index) {
@@ -143,7 +143,7 @@ define([
143143
* @param {*} scrollToElementId
144144
*/
145145
navigateTo: function (code, scrollToElementId) {
146-
var sortedItems = steps.sort(this.sortItems),
146+
var sortedItems = steps().sort(this.sortItems),
147147
bodyElem = $.browser.safari || $.browser.chrome ? $('body') : $('html');
148148

149149
scrollToElementId = scrollToElementId || null;
@@ -179,7 +179,7 @@ define([
179179
var activeIndex = 0,
180180
code;
181181

182-
steps.sort(this.sortItems).forEach(function (element, index) {
182+
steps().sort(this.sortItems).forEach(function (element, index) {
183183
if (element.isVisible()) {
184184
element.isVisible(false);
185185
activeIndex = index;

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

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
use Magento\Customer\Api\Data\AddressInterface;
1313
use Magento\Customer\Api\Data\CustomerInterface;
1414
use Magento\Customer\Api\Data\ValidationResultsInterfaceFactory;
15-
use Magento\Customer\Model\EmailNotificationInterface;
1615
use Magento\Customer\Helper\View as CustomerViewHelper;
1716
use Magento\Customer\Model\Config\Share as ConfigShare;
1817
use Magento\Customer\Model\Customer as CustomerModel;
18+
use Magento\Customer\Model\Customer\CredentialsValidator;
1919
use Magento\Customer\Model\Metadata\Validator;
2020
use Magento\Eav\Model\Validator\Attribute\Backend;
2121
use Magento\Framework\Api\ExtensibleDataObjectConverter;
2222
use Magento\Framework\App\Area;
2323
use Magento\Framework\App\Config\ScopeConfigInterface;
2424
use Magento\Framework\App\ObjectManager;
25+
use Magento\Framework\DataObjectFactory as ObjectFactory;
2526
use Magento\Framework\Encryption\EncryptorInterface as Encryptor;
2627
use Magento\Framework\Encryption\Helper\Security;
2728
use Magento\Framework\Event\ManagerInterface;
@@ -30,23 +31,22 @@
3031
use Magento\Framework\Exception\InputException;
3132
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
3233
use Magento\Framework\Exception\LocalizedException;
34+
use Magento\Framework\Exception\MailException;
3335
use Magento\Framework\Exception\NoSuchEntityException;
3436
use Magento\Framework\Exception\State\ExpiredException;
3537
use Magento\Framework\Exception\State\InputMismatchException;
3638
use Magento\Framework\Exception\State\InvalidTransitionException;
37-
use Magento\Framework\DataObjectFactory as ObjectFactory;
3839
use Magento\Framework\Exception\State\UserLockedException;
39-
use Magento\Framework\Registry;
40-
use Magento\Store\Model\ScopeInterface;
41-
use Psr\Log\LoggerInterface as PsrLogger;
42-
use Magento\Framework\Exception\MailException;
40+
use Magento\Framework\Intl\DateTimeFactory;
4341
use Magento\Framework\Mail\Template\TransportBuilder;
4442
use Magento\Framework\Math\Random;
4543
use Magento\Framework\Reflection\DataObjectProcessor;
44+
use Magento\Framework\Registry;
4645
use Magento\Framework\Stdlib\DateTime;
4746
use Magento\Framework\Stdlib\StringUtils as StringHelper;
47+
use Magento\Store\Model\ScopeInterface;
4848
use Magento\Store\Model\StoreManagerInterface;
49-
use Magento\Customer\Model\Customer\CredentialsValidator;
49+
use Psr\Log\LoggerInterface as PsrLogger;
5050

5151
/**
5252
* Handle various customer account actions
@@ -293,6 +293,11 @@ class AccountManagement implements AccountManagementInterface
293293
*/
294294
private $credentialsValidator;
295295

296+
/**
297+
* @var DateTimeFactory
298+
*/
299+
private $dateTimeFactory;
300+
296301
/**
297302
* @param CustomerFactory $customerFactory
298303
* @param ManagerInterface $eventManager
@@ -318,6 +323,7 @@ class AccountManagement implements AccountManagementInterface
318323
* @param ObjectFactory $objectFactory
319324
* @param ExtensibleDataObjectConverter $extensibleDataObjectConverter
320325
* @param CredentialsValidator|null $credentialsValidator
326+
* @param DateTimeFactory $dateTimeFactory
321327
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
322328
*/
323329
public function __construct(
@@ -344,7 +350,8 @@ public function __construct(
344350
CustomerModel $customerModel,
345351
ObjectFactory $objectFactory,
346352
ExtensibleDataObjectConverter $extensibleDataObjectConverter,
347-
CredentialsValidator $credentialsValidator = null
353+
CredentialsValidator $credentialsValidator = null,
354+
DateTimeFactory $dateTimeFactory = null
348355
) {
349356
$this->customerFactory = $customerFactory;
350357
$this->eventManager = $eventManager;
@@ -369,8 +376,9 @@ public function __construct(
369376
$this->customerModel = $customerModel;
370377
$this->objectFactory = $objectFactory;
371378
$this->extensibleDataObjectConverter = $extensibleDataObjectConverter;
372-
$this->credentialsValidator = $credentialsValidator ?: ObjectManager::getInstance()
373-
->get(CredentialsValidator::class);
379+
$this->credentialsValidator =
380+
$credentialsValidator ?: ObjectManager::getInstance()->get(CredentialsValidator::class);
381+
$this->dateTimeFactory = $dateTimeFactory ?: ObjectManager::getInstance()->get(DateTimeFactory::class);
374382
}
375383

376384
/**
@@ -380,7 +388,6 @@ public function __construct(
380388
*/
381389
private function getAuthentication()
382390
{
383-
384391
if (!($this->authentication instanceof AuthenticationInterface)) {
385392
return \Magento\Framework\App\ObjectManager::getInstance()->get(
386393
\Magento\Customer\Model\AuthenticationInterface::class
@@ -613,16 +620,16 @@ protected function makeRequiredCharactersCheck($password)
613620
$return = 0;
614621

615622
if (preg_match('/[0-9]+/', $password)) {
616-
$counter ++;
623+
$counter++;
617624
}
618625
if (preg_match('/[A-Z]+/', $password)) {
619-
$counter ++;
626+
$counter++;
620627
}
621628
if (preg_match('/[a-z]+/', $password)) {
622-
$counter ++;
629+
$counter++;
623630
}
624631
if (preg_match('/[^a-zA-Z0-9]+/', $password)) {
625-
$counter ++;
632+
$counter++;
626633
}
627634

628635
if ($counter < $requiredNumber) {
@@ -890,16 +897,14 @@ public function validate(CustomerInterface $customer)
890897

891898
$result = $this->getEavValidator()->isValid($customerModel);
892899
if ($result === false && is_array($this->getEavValidator()->getMessages())) {
893-
return $validationResults->setIsValid(false)
894-
->setMessages(
895-
call_user_func_array(
896-
'array_merge',
897-
$this->getEavValidator()->getMessages()
898-
)
899-
);
900+
return $validationResults->setIsValid(false)->setMessages(
901+
call_user_func_array(
902+
'array_merge',
903+
$this->getEavValidator()->getMessages()
904+
)
905+
);
900906
}
901-
return $validationResults->setIsValid(true)
902-
->setMessages([]);
907+
return $validationResults->setIsValid(true)->setMessages([]);
903908
}
904909

905910
/**
@@ -949,10 +954,12 @@ public function isCustomerInStore($customerWebsiteId, $storeId)
949954
private function validateResetPasswordToken($customerId, $resetPasswordLinkToken)
950955
{
951956
if (empty($customerId) || $customerId < 0) {
952-
throw new InputException(__(
953-
'Invalid value of "%value" provided for the %fieldName field.',
954-
['value' => $customerId, 'fieldName' => 'customerId']
955-
));
957+
throw new InputException(
958+
__(
959+
'Invalid value of "%value" provided for the %fieldName field.',
960+
['value' => $customerId, 'fieldName' => 'customerId']
961+
)
962+
);
956963
}
957964
if (!is_string($resetPasswordLinkToken) || empty($resetPasswordLinkToken)) {
958965
$params = ['fieldName' => 'resetPasswordLinkToken'];
@@ -1178,8 +1185,8 @@ public function isResetPasswordLinkTokenExpired($rpToken, $rpTokenCreatedAt)
11781185

11791186
$expirationPeriod = $this->customerModel->getResetPasswordLinkExpirationPeriod();
11801187

1181-
$currentTimestamp = (new \DateTime())->getTimestamp();
1182-
$tokenTimestamp = (new \DateTime($rpTokenCreatedAt))->getTimestamp();
1188+
$currentTimestamp = $this->dateTimeFactory->create()->getTimestamp();
1189+
$tokenTimestamp = $this->dateTimeFactory->create($rpTokenCreatedAt)->getTimestamp();
11831190
if ($tokenTimestamp > $currentTimestamp) {
11841191
return true;
11851192
}
@@ -1215,7 +1222,9 @@ public function changeResetPasswordLinkToken($customer, $passwordLinkToken)
12151222
if (is_string($passwordLinkToken) && !empty($passwordLinkToken)) {
12161223
$customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());
12171224
$customerSecure->setRpToken($passwordLinkToken);
1218-
$customerSecure->setRpTokenCreatedAt((new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT));
1225+
$customerSecure->setRpTokenCreatedAt(
1226+
$this->dateTimeFactory->create()->format(DateTime::DATETIME_PHP_FORMAT)
1227+
);
12191228
$this->customerRepository->save($customer);
12201229
}
12211230
return true;
@@ -1304,8 +1313,8 @@ protected function getFullCustomerObject($customer)
13041313
// No need to flatten the custom attributes or nested objects since the only usage is for email templates and
13051314
// object passed for events
13061315
$mergedCustomerData = $this->customerRegistry->retrieveSecureData($customer->getId());
1307-
$customerData = $this->dataProcessor
1308-
->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class);
1316+
$customerData =
1317+
$this->dataProcessor->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class);
13091318
$mergedCustomerData->addData($customerData);
13101319
$mergedCustomerData->setData('name', $this->customerViewHelper->getCustomerName($customer));
13111320
return $mergedCustomerData;

0 commit comments

Comments
 (0)