Skip to content

Commit d57948d

Browse files
committed
Merge branch 'github-2.3-develop' into MC-15341
2 parents 68bb22b + 5177344 commit d57948d

File tree

148 files changed

+8218
-2208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+8218
-2208
lines changed

app/code/Magento/AuthorizenetGraphQl/Model/AuthorizenetDataProvider.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99

1010
use Magento\QuoteGraphQl\Model\Cart\Payment\AdditionalDataProviderInterface;
1111
use Magento\Framework\Stdlib\ArrayManager;
12-
use Magento\Framework\GraphQL\DataObjectConverter;
1312

1413
/**
1514
* DataProvider Model for Authorizenet
1615
*/
1716
class AuthorizenetDataProvider implements AdditionalDataProviderInterface
1817
{
19-
private const PATH_ADDITIONAL_DATA = 'input/payment_method/additional_data/authorizenet_acceptjs';
18+
private const PATH_ADDITIONAL_DATA = 'authorizenet_acceptjs';
2019

2120
/**
2221
* @var ArrayManager
@@ -36,12 +35,12 @@ public function __construct(
3635
/**
3736
* Return additional data
3837
*
39-
* @param array $args
38+
* @param array $data
4039
* @return array
4140
*/
42-
public function getData(array $args): array
41+
public function getData(array $data): array
4342
{
44-
$additionalData = $this->arrayManager->get(static::PATH_ADDITIONAL_DATA, $args) ?? [];
43+
$additionalData = $this->arrayManager->get(static::PATH_ADDITIONAL_DATA, $data) ?? [];
4544
foreach ($additionalData as $key => $value) {
4645
$additionalData[$this->snakeCaseToCamelCase($key)] = $value;
4746
unset($additionalData[$key]);

app/code/Magento/Backend/Test/Mftf/Test/AdminLoginTest.xml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,8 @@
2020
<group value="login"/>
2121
</annotations>
2222

23-
<amOnPage url="{{AdminLoginPage.url}}" stepKey="amOnAdminLoginPage"/>
24-
<fillField selector="{{AdminLoginFormSection.username}}" userInput="{{_ENV.MAGENTO_ADMIN_USERNAME}}" stepKey="fillUsername"/>
25-
<fillField selector="{{AdminLoginFormSection.password}}" userInput="{{_ENV.MAGENTO_ADMIN_PASSWORD}}" stepKey="fillPassword"/>
26-
<click selector="{{AdminLoginFormSection.signIn}}" stepKey="clickOnSignIn"/>
27-
<closeAdminNotification stepKey="closeAdminNotification"/>
23+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
2824
<seeInCurrentUrl url="{{AdminLoginPage.url}}" stepKey="seeAdminLoginUrl"/>
25+
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
2926
</test>
3027
</tests>

app/code/Magento/Catalog/Model/Indexer/Product/Flat/Action/Eraser.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Magento\Framework\App\ResourceConnection;
1111
use Magento\Catalog\Model\Product\Attribute\Source\Status;
12+
use Magento\Framework\EntityManager\MetadataPool;
1213
use Magento\Store\Model\Store;
1314

1415
/**
@@ -31,19 +32,28 @@ class Eraser
3132
*/
3233
protected $storeManager;
3334

35+
/**
36+
* @var MetadataPool
37+
*/
38+
private $metadataPool;
39+
3440
/**
3541
* @param \Magento\Framework\App\ResourceConnection $resource
3642
* @param \Magento\Catalog\Helper\Product\Flat\Indexer $productHelper
3743
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
44+
* @param MetadataPool|null $metadataPool
3845
*/
3946
public function __construct(
4047
\Magento\Framework\App\ResourceConnection $resource,
4148
\Magento\Catalog\Helper\Product\Flat\Indexer $productHelper,
42-
\Magento\Store\Model\StoreManagerInterface $storeManager
49+
\Magento\Store\Model\StoreManagerInterface $storeManager,
50+
MetadataPool $metadataPool = null
4351
) {
4452
$this->productIndexerHelper = $productHelper;
4553
$this->connection = $resource->getConnection();
4654
$this->storeManager = $storeManager;
55+
$this->metadataPool = $metadataPool ?:
56+
\Magento\Framework\App\ObjectManager::getInstance()->get(MetadataPool::class);
4757
}
4858

4959
/**
@@ -81,17 +91,24 @@ public function removeDisabledProducts(array &$ids, $storeId)
8191
/* @var $statusAttribute \Magento\Eav\Model\Entity\Attribute */
8292
$statusAttribute = $this->productIndexerHelper->getAttribute('status');
8393

94+
/** @var \Magento\Framework\EntityManager\EntityMetadataInterface $metadata */
95+
$metadata = $this->metadataPool->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class);
96+
8497
$select = $this->getSelectForProducts($ids);
8598
$select->joinLeft(
8699
['status_global_attr' => $statusAttribute->getBackendTable()],
87100
' status_global_attr.attribute_id = ' . (int)$statusAttribute->getAttributeId()
88-
. ' AND status_global_attr.store_id = ' . Store::DEFAULT_STORE_ID,
101+
. ' AND status_global_attr.store_id = ' . Store::DEFAULT_STORE_ID
102+
. ' AND status_global_attr.' . $statusAttribute->getEntityIdField() . '='
103+
. 'product_table.' . $metadata->getLinkField(),
89104
[]
90105
);
91106
$select->joinLeft(
92107
['status_attr' => $statusAttribute->getBackendTable()],
93108
' status_attr.attribute_id = ' . (int)$statusAttribute->getAttributeId()
94-
. ' AND status_attr.store_id = ' . $storeId,
109+
. ' AND status_attr.store_id = ' . $storeId
110+
. ' AND status_attr.' . $statusAttribute->getEntityIdField() . '='
111+
. 'product_table.' . $metadata->getLinkField(),
95112
[]
96113
);
97114
$select->where('IFNULL(status_attr.value, status_global_attr.value) = ?', Status::STATUS_DISABLED);

app/code/Magento/Catalog/Model/ResourceModel/Product/Image.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ private function getUsedImagesSelect(): Select
158158
'value as filepath'
159159
)->joinInner(
160160
['image_value' => $this->resourceConnection->getTableName(Gallery::GALLERY_VALUE_TABLE)],
161-
'images.value_id = image_value.value_id'
161+
'images.value_id = image_value.value_id',
162+
[]
162163
)->where(
163164
'images.disabled = 0 AND image_value.disabled = 0'
164165
);

app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/paging/sizes.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ define([
99

1010
return Sizes.extend({
1111
defaults: {
12-
excludedOptions: ['100', '200']
13-
},
14-
15-
/**
16-
* @override
17-
*/
18-
initialize: function () {
19-
this._super();
20-
21-
this.excludedOptions.forEach(function (excludedOption) {
22-
delete this.options[excludedOption];
23-
}, this);
24-
this.updateArray();
25-
26-
return this;
12+
options: {
13+
'20': {
14+
value: 20,
15+
label: 20
16+
},
17+
'30': {
18+
value: 30,
19+
label: 30
20+
},
21+
'50': {
22+
value: 50,
23+
label: 50
24+
}
25+
},
26+
value: 20
2727
}
2828
});
2929
});

app/code/Magento/CustomerGraphQl/Model/Context/AddUserInfoToContext.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,27 @@ public function execute(ContextParametersInterface $contextParameters): ContextP
3939
if (null !== $currentUserId) {
4040
$currentUserId = (int)$currentUserId;
4141
}
42+
$contextParameters->setUserId($currentUserId);
4243

4344
$currentUserType = $this->userContext->getUserType();
4445
if (null !== $currentUserType) {
4546
$currentUserType = (int)$currentUserType;
4647
}
47-
48-
$contextParameters->setUserId($currentUserId);
4948
$contextParameters->setUserType($currentUserType);
49+
50+
$contextParameters->addExtensionAttribute('is_customer', $this->isCustomer($currentUserId, $currentUserType));
5051
return $contextParameters;
5152
}
53+
54+
/**
55+
* Checking if current user is logged
56+
*
57+
* @param int|null $customerId
58+
* @param int|null $customerType
59+
* @return bool
60+
*/
61+
private function isCustomer(?int $customerId, ?int $customerType): bool
62+
{
63+
return !empty($customerId) && !empty($customerType) && $customerType !== UserContextInterface::USER_TYPE_GUEST;
64+
}
5265
}

app/code/Magento/CustomerGraphQl/Model/Customer/GetCustomer.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\CustomerGraphQl\Model\Customer;
99

10-
use Magento\Authorization\Model\UserContextInterface;
1110
use Magento\Customer\Api\AccountManagementInterface;
1211
use Magento\Customer\Api\CustomerRepositoryInterface;
1312
use Magento\Customer\Api\Data\CustomerInterface;
@@ -18,7 +17,7 @@
1817
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1918
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
2019
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
21-
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
20+
use Magento\GraphQl\Model\Query\ContextInterface;
2221

2322
/**
2423
* Get customer
@@ -68,11 +67,6 @@ public function __construct(
6867
public function execute(ContextInterface $context): CustomerInterface
6968
{
7069
$currentUserId = $context->getUserId();
71-
$currentUserType = $context->getUserType();
72-
73-
if (true === $this->isUserGuest($currentUserId, $currentUserType)) {
74-
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
75-
}
7670

7771
try {
7872
$customer = $this->customerRepository->getById($currentUserId);
@@ -100,19 +94,4 @@ public function execute(ContextInterface $context): CustomerInterface
10094
}
10195
return $customer;
10296
}
103-
104-
/**
105-
* Checking if current customer is guest
106-
*
107-
* @param int|null $customerId
108-
* @param int|null $customerType
109-
* @return bool
110-
*/
111-
private function isUserGuest(?int $customerId, ?int $customerType): bool
112-
{
113-
if (null === $customerId || null === $customerType) {
114-
return true;
115-
}
116-
return 0 === (int)$customerId || (int)$customerType === UserContextInterface::USER_TYPE_GUEST;
117-
}
11897
}

app/code/Magento/CustomerGraphQl/Model/Resolver/ChangePassword.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
use Magento\CustomerGraphQl\Model\Customer\GetCustomer;
1414
use Magento\Framework\Exception\LocalizedException;
1515
use Magento\Framework\GraphQl\Config\Element\Field;
16+
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1617
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1718
use Magento\Framework\GraphQl\Query\ResolverInterface;
1819
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
20+
use Magento\GraphQl\Model\Query\ContextInterface;
1921

2022
/**
2123
* Change customer password resolver
@@ -70,6 +72,11 @@ public function resolve(
7072
array $value = null,
7173
array $args = null
7274
) {
75+
/** @var ContextInterface $context */
76+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
77+
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
78+
}
79+
7380
if (!isset($args['currentPassword']) || '' == trim($args['currentPassword'])) {
7481
throw new GraphQlInputException(__('Specify the "currentPassword" value.'));
7582
}
@@ -78,16 +85,16 @@ public function resolve(
7885
throw new GraphQlInputException(__('Specify the "newPassword" value.'));
7986
}
8087

81-
$customer = $this->getCustomer->execute($context);
82-
$customerId = (int)$customer->getId();
83-
88+
$customerId = $context->getUserId();
8489
$this->checkCustomerPassword->execute($args['currentPassword'], $customerId);
8590

8691
try {
8792
$this->accountManagement->changePasswordById($customerId, $args['currentPassword'], $args['newPassword']);
8893
} catch (LocalizedException $e) {
8994
throw new GraphQlInputException(__($e->getMessage()), $e);
9095
}
96+
97+
$customer = $this->getCustomer->execute($context);
9198
return $this->extractCustomerData->execute($customer);
9299
}
93100
}

app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function resolve(
5151
array $value = null,
5252
array $args = null
5353
) {
54-
if (!isset($args['input']) || !is_array($args['input']) || empty($args['input'])) {
54+
if (empty($args['input']) || !is_array($args['input'])) {
5555
throw new GraphQlInputException(__('"input" value should be specified'));
5656
}
5757

app/code/Magento/CustomerGraphQl/Model/Resolver/CreateCustomerAddress.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,18 @@
99

1010
use Magento\CustomerGraphQl\Model\Customer\Address\CreateCustomerAddress as CreateCustomerAddressModel;
1111
use Magento\CustomerGraphQl\Model\Customer\Address\ExtractCustomerAddressData;
12-
use Magento\CustomerGraphQl\Model\Customer\GetCustomer;
12+
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1313
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1414
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1515
use Magento\Framework\GraphQl\Config\Element\Field;
1616
use Magento\Framework\GraphQl\Query\ResolverInterface;
17+
use Magento\GraphQl\Model\Query\ContextInterface;
1718

1819
/**
1920
* Customers address create, used for GraphQL request processing
2021
*/
2122
class CreateCustomerAddress implements ResolverInterface
2223
{
23-
/**
24-
* @var GetCustomer
25-
*/
26-
private $getCustomer;
27-
2824
/**
2925
* @var CreateCustomerAddressModel
3026
*/
@@ -36,16 +32,13 @@ class CreateCustomerAddress implements ResolverInterface
3632
private $extractCustomerAddressData;
3733

3834
/**
39-
* @param GetCustomer $getCustomer
4035
* @param CreateCustomerAddressModel $createCustomerAddress
4136
* @param ExtractCustomerAddressData $extractCustomerAddressData
4237
*/
4338
public function __construct(
44-
GetCustomer $getCustomer,
4539
CreateCustomerAddressModel $createCustomerAddress,
4640
ExtractCustomerAddressData $extractCustomerAddressData
4741
) {
48-
$this->getCustomer = $getCustomer;
4942
$this->createCustomerAddress = $createCustomerAddress;
5043
$this->extractCustomerAddressData = $extractCustomerAddressData;
5144
}
@@ -60,13 +53,16 @@ public function resolve(
6053
array $value = null,
6154
array $args = null
6255
) {
63-
if (!isset($args['input']) || !is_array($args['input']) || empty($args['input'])) {
64-
throw new GraphQlInputException(__('"input" value should be specified'));
56+
/** @var ContextInterface $context */
57+
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
58+
throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
6559
}
6660

67-
$customer = $this->getCustomer->execute($context);
61+
if (empty($args['input']) || !is_array($args['input'])) {
62+
throw new GraphQlInputException(__('"input" value should be specified'));
63+
}
6864

69-
$address = $this->createCustomerAddress->execute((int)$customer->getId(), $args['input']);
65+
$address = $this->createCustomerAddress->execute($context->getUserId(), $args['input']);
7066
return $this->extractCustomerAddressData->execute($address);
7167
}
7268
}

0 commit comments

Comments
 (0)