Skip to content

Commit c2603c4

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MC-17533
2 parents 0e30345 + bcfe16f commit c2603c4

File tree

48 files changed

+1125
-215
lines changed

Some content is hidden

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

48 files changed

+1125
-215
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The Magento 2 development team or community maintainers will review all issues a
1111
During the review we might require clarifications from the contributor.
1212
If there is no response from the contributor within two weeks, the pull request will be closed.
1313

14-
For more detialed information on contribution please read our [beginners guide](https://github.com/magento/magento2/wiki/Getting-Started).
14+
For more detailed information on contribution please read our [beginners guide](https://github.com/magento/magento2/wiki/Getting-Started).
1515

1616
## Contribution requirements
1717

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/view/adminhtml/web/js/category-tree.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ define([
3737
ajax: {
3838
url: options.url,
3939
type: 'POST',
40-
success: $.proxy(function (node) {
41-
return this._convertData(node[0]);
40+
success: $.proxy(function (nodes) {
41+
return this._convertDataNodes(nodes);
4242
}, this),
4343

4444
/**
@@ -77,6 +77,21 @@ define([
7777
}
7878
},
7979

80+
/**
81+
* @param {Array} nodes
82+
* @returns {Array}
83+
* @private
84+
*/
85+
_convertDataNodes: function (nodes) {
86+
var nodesData = [];
87+
88+
nodes.forEach(function (node) {
89+
nodesData.push(this._convertData(node));
90+
}, this);
91+
92+
return nodesData;
93+
},
94+
8095
/**
8196
* @param {Object} node
8297
* @return {*}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Cms\Model\Plugin;
9+
10+
use Magento\Catalog\Model\Product as CatalogProduct;
11+
use Magento\Cms\Model\Page;
12+
13+
/**
14+
* Cleaning no-route page cache for the product details page after enabling product that is not assigned to a category
15+
*/
16+
class Product
17+
{
18+
/**
19+
* @var Page
20+
*/
21+
private $page;
22+
23+
/**
24+
* @param Page $page
25+
*/
26+
public function __construct(Page $page)
27+
{
28+
$this->page = $page;
29+
}
30+
31+
/**
32+
* After get identities
33+
*
34+
* @param CatalogProduct $product
35+
* @param array $identities
36+
* @return array
37+
*/
38+
public function afterGetIdentities(CatalogProduct $product, array $identities)
39+
{
40+
if ($product->getOrigData('status') > $product->getData('status')) {
41+
if (empty($product->getCategoryIds())) {
42+
$noRoutePage = $this->page->load(Page::NOROUTE_PAGE_ID);
43+
$noRoutePageId = $noRoutePage->getId();
44+
$identities[] = Page::CACHE_TAG . '_' . $noRoutePageId;
45+
}
46+
}
47+
48+
return array_unique($identities);
49+
}
50+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Cms\Test\Unit\Model\Plugin;
9+
10+
use Magento\Catalog\Model\Product as CatalogProduct;
11+
use Magento\Cms\Model\Page;
12+
use Magento\Cms\Model\Plugin\Product;
13+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
14+
use PHPUnit_Framework_MockObject_MockObject as MockObject;
15+
use PHPUnit\Framework\TestCase;
16+
17+
/**
18+
* Product plugin test
19+
*/
20+
class ProductTest extends TestCase
21+
{
22+
/**
23+
* @var Product
24+
*/
25+
private $plugin;
26+
27+
/**
28+
* @var MockObject|CatalogProduct
29+
*/
30+
private $product;
31+
32+
/**
33+
* @var MockObject|Page
34+
*/
35+
private $page;
36+
37+
/**
38+
* @inheritdoc
39+
*/
40+
protected function setUp()
41+
{
42+
$objectManager = new ObjectManager($this);
43+
44+
$this->product = $this->getMockBuilder(CatalogProduct::class)
45+
->disableOriginalConstructor()
46+
->setMethods(['getEntityId', 'getOrigData', 'getData', 'getCategoryIds'])
47+
->getMock();
48+
49+
$this->page = $this->getMockBuilder(Page::class)
50+
->disableOriginalConstructor()
51+
->setMethods(['getId', 'load'])
52+
->getMock();
53+
54+
$this->plugin = $objectManager->getObject(
55+
Product::class,
56+
[
57+
'page' => $this->page
58+
]
59+
);
60+
}
61+
62+
public function testAfterGetIdentities()
63+
{
64+
$baseIdentities = [
65+
'SomeCacheId',
66+
'AnotherCacheId',
67+
];
68+
$id = 12345;
69+
$pageId = 1;
70+
$expectedIdentities = [
71+
'SomeCacheId',
72+
'AnotherCacheId',
73+
Page::CACHE_TAG . '_' . $pageId,
74+
];
75+
76+
$this->product->method('getEntityId')
77+
->willReturn($id);
78+
$this->product->method('getOrigData')
79+
->with('status')
80+
->willReturn(2);
81+
$this->product->method('getData')
82+
->with('status')
83+
->willReturn(1);
84+
$this->page->method('getId')
85+
->willReturn(1);
86+
$this->page->method('load')
87+
->willReturnSelf();
88+
89+
$identities = $this->plugin->afterGetIdentities($this->product, $baseIdentities);
90+
91+
$this->assertEquals($expectedIdentities, $identities);
92+
}
93+
}

app/code/Magento/Cms/etc/di.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,7 @@
233233
</argument>
234234
</arguments>
235235
</type>
236+
<type name="Magento\Catalog\Model\Product">
237+
<plugin name="cms" type="Magento\Cms\Model\Plugin\Product" sortOrder="100"/>
238+
</type>
236239
</config>
237-
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\CustomerGraphQl\Model\Context;
9+
10+
use Magento\Authorization\Model\UserContextInterface;
11+
use Magento\GraphQl\Model\Query\ContextParametersInterface;
12+
use Magento\GraphQl\Model\Query\ContextParametersProcessorInterface;
13+
14+
/**
15+
* @inheritdoc
16+
*/
17+
class AddUserInfoToContext implements ContextParametersProcessorInterface
18+
{
19+
/**
20+
* @var UserContextInterface
21+
*/
22+
private $userContext;
23+
24+
/**
25+
* @param UserContextInterface $userContext
26+
*/
27+
public function __construct(
28+
UserContextInterface $userContext
29+
) {
30+
$this->userContext = $userContext;
31+
}
32+
33+
/**
34+
* @inheritdoc
35+
*/
36+
public function execute(ContextParametersInterface $contextParameters): ContextParametersInterface
37+
{
38+
$currentUserId = $this->userContext->getUserId();
39+
if (null !== $currentUserId) {
40+
$currentUserId = (int)$currentUserId;
41+
}
42+
43+
$currentUserType = $this->userContext->getUserType();
44+
if (null !== $currentUserType) {
45+
$currentUserType = (int)$currentUserType;
46+
}
47+
48+
$contextParameters->setUserId($currentUserId);
49+
$contextParameters->setUserType($currentUserType);
50+
return $contextParameters;
51+
}
52+
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Magento\Framework\Exception\AlreadyExistsException;
1212
use Magento\Framework\Exception\LocalizedException;
1313
use Magento\Framework\GraphQl\Exception\GraphQlAlreadyExistsException;
14-
use Magento\Framework\GraphQl\Exception\GraphQlAuthenticationException;
1514
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1615
use Magento\Customer\Api\Data\CustomerInterface;
1716

@@ -39,7 +38,6 @@ public function __construct(
3938
*
4039
* @param CustomerInterface $customer
4140
* @throws GraphQlAlreadyExistsException
42-
* @throws GraphQlAuthenticationException
4341
* @throws GraphQlInputException
4442
*/
4543
public function execute(CustomerInterface $customer): void

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\CustomerGraphQl\Model\Resolver;
99

10-
use Magento\Authorization\Model\UserContextInterface;
1110
use Magento\CustomerGraphQl\Model\Customer\CreateCustomerAccount;
1211
use Magento\CustomerGraphQl\Model\Customer\ExtractCustomerData;
1312
use Magento\Framework\GraphQl\Config\Element\Field;
@@ -58,9 +57,6 @@ public function resolve(
5857

5958
$customer = $this->createCustomerAccount->execute($args['input']);
6059

61-
$context->setUserId((int)$customer->getId());
62-
$context->setUserType(UserContextInterface::USER_TYPE_CUSTOMER);
63-
6460
$data = $this->extractCustomerData->execute($customer);
6561
return ['customer' => $data];
6662
}

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Magento\CustomerGraphQl\Model\Resolver;
99

10-
use Magento\CustomerGraphQl\Model\Customer\GetCustomer;
10+
use Magento\Framework\Exception\LocalizedException;
1111
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
1212
use Magento\Framework\GraphQl\Config\Element\Field;
1313
use Magento\Framework\GraphQl\Query\ResolverInterface;
@@ -18,25 +18,17 @@
1818
*/
1919
class IsSubscribed implements ResolverInterface
2020
{
21-
/**
22-
* @var GetCustomer
23-
*/
24-
private $getCustomer;
25-
2621
/**
2722
* @var SubscriberFactory
2823
*/
2924
private $subscriberFactory;
3025

3126
/**
32-
* @param GetCustomer $getCustomer
3327
* @param SubscriberFactory $subscriberFactory
3428
*/
3529
public function __construct(
36-
GetCustomer $getCustomer,
3730
SubscriberFactory $subscriberFactory
3831
) {
39-
$this->getCustomer = $getCustomer;
4032
$this->subscriberFactory = $subscriberFactory;
4133
}
4234

@@ -50,7 +42,11 @@ public function resolve(
5042
array $value = null,
5143
array $args = null
5244
) {
53-
$customer = $this->getCustomer->execute($context);
45+
if (!isset($value['model'])) {
46+
throw new LocalizedException(__('"model" value should be specified'));
47+
}
48+
/** @var Customer $customer */
49+
$customer = $value['model'];
5450

5551
$status = $this->subscriberFactory->create()->loadByCustomerId((int)$customer->getId())->isSubscribed();
5652
return (bool)$status;

0 commit comments

Comments
 (0)