Skip to content

Commit

Permalink
Merge branch '2.2-develop' of github.com:magento/magento2 into MAGETW…
Browse files Browse the repository at this point in the history
…O-70954
  • Loading branch information
briscoda committed Oct 27, 2017
2 parents c5b2a0f + 73c7ac2 commit fe44f8f
Show file tree
Hide file tree
Showing 62 changed files with 694 additions and 222 deletions.
4 changes: 2 additions & 2 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
############################################
## adjust memory limit

php_value memory_limit 768M
php_value memory_limit 756M
php_value max_execution_time 18000

############################################
Expand All @@ -59,7 +59,7 @@
############################################
## adjust memory limit

php_value memory_limit 768M
php_value memory_limit 756M
php_value max_execution_time 18000

############################################
Expand Down
2 changes: 1 addition & 1 deletion .htaccess.sample
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
############################################
## adjust memory limit

php_value memory_limit 768M
php_value memory_limit 756M
php_value max_execution_time 18000

############################################
Expand Down
2 changes: 1 addition & 1 deletion .user.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
memory_limit = 768M
memory_limit = 756M
max_execution_time = 18000
session.auto_start = off
suhosin.session.cryptua = off
2 changes: 2 additions & 0 deletions app/code/Magento/Backend/Block/Dashboard/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ public function getChartUrl($directUrl = true)
$tmpstring = implode('|', $this->_axisLabels[$idx]);

$valueBuffer[] = $indexid . ":|" . $tmpstring;
} elseif ($idx == 'y') {
$valueBuffer[] = $indexid . ":|" . implode('|', $yLabels);
}
$indexid++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function save(\Magento\Eav\Api\Data\AttributeSetInterface $attributeSet)
*/
public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria)
{
$this->searchCriteriaBuilder->setFilterGroups((array)$searchCriteria->getFilterGroups());
$this->searchCriteriaBuilder->addFilters(
[
$this->filterBuilder
Expand All @@ -71,9 +72,15 @@ public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCr
->create(),
]
);

$this->searchCriteriaBuilder->setSortOrders((array)$searchCriteria->getSortOrders());
$this->searchCriteriaBuilder->setCurrentPage($searchCriteria->getCurrentPage());
$this->searchCriteriaBuilder->setPageSize($searchCriteria->getPageSize());
return $this->attributeSetRepository->getList($this->searchCriteriaBuilder->create());

$searchResult = $this->attributeSetRepository->getList($this->searchCriteriaBuilder->create());
$searchResult->setSearchCriteria($searchCriteria);

return $searchResult;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private function cacheProduct($cacheKey, \Magento\Catalog\Api\Data\ProductInterf
if ($this->cacheLimit && count($this->instances) > $this->cacheLimit) {
$offset = round($this->cacheLimit / -2);
$this->instancesById = array_slice($this->instancesById, $offset, null, true);
$this->instances = array_slice($this->instances, $offset);
$this->instances = array_slice($this->instances, $offset, null, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ switch ($type = $block->getType()) {
<?= $block->getReviewsSummaryHtml($_item, $templateType) ?>
<?php endif; ?>

<?php if (!$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if ($canItemsAddToCart && !$_item->isComposite() && $_item->isSaleable() && $type == 'related'): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<div class="field choice related">
<input type="checkbox" class="checkbox related" id="related-checkbox<?= /* @escapeNotVerified */ $_item->getId() ?>" name="related_products[]" value="<?= /* @escapeNotVerified */ $_item->getId() ?>" />
Expand Down
27 changes: 13 additions & 14 deletions app/code/Magento/Checkout/Block/Checkout/AttributeMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,19 @@ protected function getFieldConfig(

$element = [
'component' => isset($additionalConfig['component']) ? $additionalConfig['component'] : $uiComponent,
'config' => [
// customScope is used to group elements within a single form (e.g. they can be validated separately)
'customScope' => $dataScopePrefix,
'customEntry' => isset($additionalConfig['config']['customEntry'])
? $additionalConfig['config']['customEntry']
: null,
'template' => 'ui/form/field',
'elementTmpl' => isset($additionalConfig['config']['elementTmpl'])
? $additionalConfig['config']['elementTmpl']
: $elementTemplate,
'tooltip' => isset($additionalConfig['config']['tooltip'])
? $additionalConfig['config']['tooltip']
: null
],
'config' => $this->mergeConfigurationNode(
'config',
$additionalConfig,
[
'config' => [
// customScope is used to group elements within a single
// form (e.g. they can be validated separately)
'customScope' => $dataScopePrefix,
'template' => 'ui/form/field',
'elementTmpl' => $elementTemplate,
],
]
),
'dataScope' => $dataScopePrefix . '.' . $attributeCode,
'label' => $attributeConfig['label'],
'provider' => $providerName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ define([
quoteId: quoteId
} : {},
urls = {
'guest': '/guest-carts/' + quoteId + '/coupons/' + couponCode,
'customer': '/carts/mine/coupons/' + couponCode
'guest': '/guest-carts/' + quoteId + '/coupons/' + encodeURIComponent(couponCode),
'customer': '/carts/mine/coupons/' + encodeURIComponent(couponCode)
};

return this.getUrl(urls, params);
Expand Down
16 changes: 15 additions & 1 deletion app/code/Magento/Customer/Block/Widget/Dob.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ public function getFieldHtml()
'max_date' => '-1d',
'change_month' => 'true',
'change_year' => 'true',
'show_on' => 'both'
'show_on' => 'both',
'first_day' => $this->getFirstDay()
]);
return $this->dateElement->getHtml();
}
Expand Down Expand Up @@ -307,4 +308,17 @@ public function getMaxDateRange()
}
return null;
}

/**
* Return first day of the week
*
* @return int
*/
public function getFirstDay()
{
return (int)$this->_scopeConfig->getValue(
'general/locale/firstday',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
}
92 changes: 50 additions & 42 deletions app/code/Magento/Customer/Model/AccountManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
use Magento\Customer\Api\Data\AddressInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Api\Data\ValidationResultsInterfaceFactory;
use Magento\Customer\Model\EmailNotificationInterface;
use Magento\Customer\Helper\View as CustomerViewHelper;
use Magento\Customer\Model\Config\Share as ConfigShare;
use Magento\Customer\Model\Customer as CustomerModel;
use Magento\Customer\Model\Customer\CredentialsValidator;
use Magento\Customer\Model\Metadata\Validator;
use Magento\Eav\Model\Validator\Attribute\Backend;
use Magento\Framework\Api\ExtensibleDataObjectConverter;
use Magento\Framework\App\Area;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\DataObjectFactory as ObjectFactory;
use Magento\Framework\Encryption\EncryptorInterface as Encryptor;
use Magento\Framework\Encryption\Helper\Security;
use Magento\Framework\Event\ManagerInterface;
Expand All @@ -30,23 +31,22 @@
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\MailException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Exception\State\ExpiredException;
use Magento\Framework\Exception\State\InputMismatchException;
use Magento\Framework\Exception\State\InvalidTransitionException;
use Magento\Framework\DataObjectFactory as ObjectFactory;
use Magento\Framework\Exception\State\UserLockedException;
use Magento\Framework\Registry;
use Magento\Store\Model\ScopeInterface;
use Psr\Log\LoggerInterface as PsrLogger;
use Magento\Framework\Exception\MailException;
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Mail\Template\TransportBuilder;
use Magento\Framework\Math\Random;
use Magento\Framework\Reflection\DataObjectProcessor;
use Magento\Framework\Registry;
use Magento\Framework\Stdlib\DateTime;
use Magento\Framework\Stdlib\StringUtils as StringHelper;
use Magento\Store\Model\ScopeInterface;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Customer\Model\Customer\CredentialsValidator;
use Psr\Log\LoggerInterface as PsrLogger;

/**
* Handle various customer account actions
Expand Down Expand Up @@ -293,6 +293,11 @@ class AccountManagement implements AccountManagementInterface
*/
private $credentialsValidator;

/**
* @var DateTimeFactory
*/
private $dateTimeFactory;

/**
* @param CustomerFactory $customerFactory
* @param ManagerInterface $eventManager
Expand All @@ -318,6 +323,7 @@ class AccountManagement implements AccountManagementInterface
* @param ObjectFactory $objectFactory
* @param ExtensibleDataObjectConverter $extensibleDataObjectConverter
* @param CredentialsValidator|null $credentialsValidator
* @param DateTimeFactory $dateTimeFactory
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
Expand All @@ -344,7 +350,8 @@ public function __construct(
CustomerModel $customerModel,
ObjectFactory $objectFactory,
ExtensibleDataObjectConverter $extensibleDataObjectConverter,
CredentialsValidator $credentialsValidator = null
CredentialsValidator $credentialsValidator = null,
DateTimeFactory $dateTimeFactory = null
) {
$this->customerFactory = $customerFactory;
$this->eventManager = $eventManager;
Expand All @@ -369,8 +376,9 @@ public function __construct(
$this->customerModel = $customerModel;
$this->objectFactory = $objectFactory;
$this->extensibleDataObjectConverter = $extensibleDataObjectConverter;
$this->credentialsValidator = $credentialsValidator ?: ObjectManager::getInstance()
->get(CredentialsValidator::class);
$this->credentialsValidator =
$credentialsValidator ?: ObjectManager::getInstance()->get(CredentialsValidator::class);
$this->dateTimeFactory = $dateTimeFactory ?: ObjectManager::getInstance()->get(DateTimeFactory::class);
}

/**
Expand All @@ -380,7 +388,6 @@ public function __construct(
*/
private function getAuthentication()
{

if (!($this->authentication instanceof AuthenticationInterface)) {
return \Magento\Framework\App\ObjectManager::getInstance()->get(
\Magento\Customer\Model\AuthenticationInterface::class
Expand Down Expand Up @@ -613,16 +620,16 @@ protected function makeRequiredCharactersCheck($password)
$return = 0;

if (preg_match('/[0-9]+/', $password)) {
$counter ++;
$counter++;
}
if (preg_match('/[A-Z]+/', $password)) {
$counter ++;
$counter++;
}
if (preg_match('/[a-z]+/', $password)) {
$counter ++;
$counter++;
}
if (preg_match('/[^a-zA-Z0-9]+/', $password)) {
$counter ++;
$counter++;
}

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

$result = $this->getEavValidator()->isValid($customerModel);
if ($result === false && is_array($this->getEavValidator()->getMessages())) {
return $validationResults->setIsValid(false)
->setMessages(
call_user_func_array(
'array_merge',
$this->getEavValidator()->getMessages()
)
);
return $validationResults->setIsValid(false)->setMessages(
call_user_func_array(
'array_merge',
$this->getEavValidator()->getMessages()
)
);
}
return $validationResults->setIsValid(true)
->setMessages([]);
return $validationResults->setIsValid(true)->setMessages([]);
}

/**
Expand Down Expand Up @@ -949,10 +954,12 @@ public function isCustomerInStore($customerWebsiteId, $storeId)
private function validateResetPasswordToken($customerId, $resetPasswordLinkToken)
{
if (empty($customerId) || $customerId < 0) {
throw new InputException(__(
'Invalid value of "%value" provided for the %fieldName field.',
['value' => $customerId, 'fieldName' => 'customerId']
));
throw new InputException(
__(
'Invalid value of "%value" provided for the %fieldName field.',
['value' => $customerId, 'fieldName' => 'customerId']
)
);
}
if (!is_string($resetPasswordLinkToken) || empty($resetPasswordLinkToken)) {
$params = ['fieldName' => 'resetPasswordLinkToken'];
Expand Down Expand Up @@ -1076,10 +1083,10 @@ protected function getTemplateTypes()
* self::NEW_ACCOUNT_EMAIL_CONFIRMATION email with confirmation link
*/
$types = [
self::NEW_ACCOUNT_EMAIL_REGISTERED => self::XML_PATH_REGISTER_EMAIL_TEMPLATE,
self::NEW_ACCOUNT_EMAIL_REGISTERED => self::XML_PATH_REGISTER_EMAIL_TEMPLATE,
self::NEW_ACCOUNT_EMAIL_REGISTERED_NO_PASSWORD => self::XML_PATH_REGISTER_NO_PASSWORD_EMAIL_TEMPLATE,
self::NEW_ACCOUNT_EMAIL_CONFIRMED => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE,
self::NEW_ACCOUNT_EMAIL_CONFIRMATION => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE,
self::NEW_ACCOUNT_EMAIL_CONFIRMED => self::XML_PATH_CONFIRMED_EMAIL_TEMPLATE,
self::NEW_ACCOUNT_EMAIL_CONFIRMATION => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE,
];
return $types;
}
Expand Down Expand Up @@ -1109,12 +1116,11 @@ protected function sendEmailTemplate(
$email = $customer->getEmail();
}

$transport = $this->transportBuilder->setTemplateIdentifier($templateId)
->setTemplateOptions(['area' => Area::AREA_FRONTEND, 'store' => $storeId])
->setTemplateVars($templateParams)
->setFrom($this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId))
->addTo($email, $this->customerViewHelper->getCustomerName($customer))
->getTransport();
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(
['area' => Area::AREA_FRONTEND, 'store' => $storeId]
)->setTemplateVars($templateParams)->setFrom(
$this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId)
)->addTo($email, $this->customerViewHelper->getCustomerName($customer))->getTransport();

$transport->sendMessage();

Expand Down Expand Up @@ -1178,8 +1184,8 @@ public function isResetPasswordLinkTokenExpired($rpToken, $rpTokenCreatedAt)

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

$currentTimestamp = (new \DateTime())->getTimestamp();
$tokenTimestamp = (new \DateTime($rpTokenCreatedAt))->getTimestamp();
$currentTimestamp = $this->dateTimeFactory->create()->getTimestamp();
$tokenTimestamp = $this->dateTimeFactory->create($rpTokenCreatedAt)->getTimestamp();
if ($tokenTimestamp > $currentTimestamp) {
return true;
}
Expand Down Expand Up @@ -1215,7 +1221,9 @@ public function changeResetPasswordLinkToken($customer, $passwordLinkToken)
if (is_string($passwordLinkToken) && !empty($passwordLinkToken)) {
$customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());
$customerSecure->setRpToken($passwordLinkToken);
$customerSecure->setRpTokenCreatedAt((new \DateTime())->format(DateTime::DATETIME_PHP_FORMAT));
$customerSecure->setRpTokenCreatedAt(
$this->dateTimeFactory->create()->format(DateTime::DATETIME_PHP_FORMAT)
);
$this->customerRepository->save($customer);
}
return true;
Expand Down Expand Up @@ -1304,8 +1312,8 @@ protected function getFullCustomerObject($customer)
// No need to flatten the custom attributes or nested objects since the only usage is for email templates and
// object passed for events
$mergedCustomerData = $this->customerRegistry->retrieveSecureData($customer->getId());
$customerData = $this->dataProcessor
->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class);
$customerData =
$this->dataProcessor->buildOutputDataArray($customer, \Magento\Customer\Api\Data\CustomerInterface::class);
$mergedCustomerData->addData($customerData);
$mergedCustomerData->setData('name', $this->customerViewHelper->getCustomerName($customer));
return $mergedCustomerData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $pa
$savedCustomer = $this->get($customer->getEmail(), $customer->getWebsiteId());
$this->eventManager->dispatch(
'customer_save_after_data_object',
['customer_data_object' => $savedCustomer, 'orig_customer_data_object' => $customer]
['customer_data_object' => $savedCustomer, 'orig_customer_data_object' => $prevCustomerData]
);
return $savedCustomer;
}
Expand Down
Loading

0 comments on commit fe44f8f

Please sign in to comment.