Skip to content

Commit f797367

Browse files
author
Alexander Akimov
authored
Merge pull request #1155 from magento-troll/troll-bugfix-pr
[Troll] Bugfixes
2 parents cd4d690 + d2a2ef9 commit f797367

File tree

26 files changed

+693
-151
lines changed

26 files changed

+693
-151
lines changed

app/code/Magento/Catalog/Setup/UpgradeSchema.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\Setup\ModuleContextInterface;
1212
use Magento\Framework\Setup\SchemaSetupInterface;
1313
use Magento\Framework\Setup\UpgradeSchemaInterface;
14+
use Magento\Framework\DB\Ddl\Table;
1415

1516
/**
1617
* Upgrade the Catalog module DB scheme
@@ -57,7 +58,13 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
5758
$setup->getConnection()->modifyColumn(
5859
$setup->getTable($table),
5960
'customer_group_id',
60-
['type' => 'integer', 'nullable' => false]
61+
[
62+
'type' => Table::TYPE_INTEGER,
63+
'nullable' => false,
64+
'unsigned' => true,
65+
'default' => '0',
66+
'comment' => 'Customer Group ID',
67+
]
6168
);
6269
}
6370
$this->recreateCatalogCategoryProductIndexTmpTable($setup);
@@ -80,6 +87,37 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
8087
'catalog_category_product_index_replica'
8188
);
8289
}
90+
91+
if (version_compare($context->getVersion(), '2.2.2', '<')) {
92+
$tables = [
93+
'catalog_product_entity_tier_price',
94+
'catalog_product_index_price_cfg_opt_agr_idx',
95+
'catalog_product_index_price_cfg_opt_agr_tmp',
96+
'catalog_product_index_price_cfg_opt_idx',
97+
'catalog_product_index_price_cfg_opt_tmp',
98+
'catalog_product_index_price_final_idx',
99+
'catalog_product_index_price_final_tmp',
100+
'catalog_product_index_price_idx',
101+
'catalog_product_index_price_opt_agr_idx',
102+
'catalog_product_index_price_opt_agr_tmp',
103+
'catalog_product_index_price_opt_idx',
104+
'catalog_product_index_price_opt_tmp',
105+
'catalog_product_index_price_tmp',
106+
];
107+
foreach ($tables as $table) {
108+
$setup->getConnection()->modifyColumn(
109+
$setup->getTable($table),
110+
'customer_group_id',
111+
[
112+
'type' => Table::TYPE_INTEGER,
113+
'nullable' => false,
114+
'unsigned' => true,
115+
'default' => '0',
116+
'comment' => 'Customer Group ID',
117+
]
118+
);
119+
}
120+
}
83121
$setup->endSetup();
84122
}
85123

app/code/Magento/Catalog/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Catalog" setup_version="2.2.1">
9+
<module name="Magento_Catalog" setup_version="2.2.2">
1010
<sequence>
1111
<module name="Magento_Eav"/>
1212
<module name="Magento_Cms"/>

app/code/Magento/ConfigurableProduct/Block/Adminhtml/Product/Steps/SelectAttributes.php

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828
\Magento\Framework\Registry $registry
2929
) {
3030
parent::__construct($context);
31-
$this->registry = $registry;
31+
$this->coreRegistry = $registry;
3232
}
3333

3434
/**
@@ -43,31 +43,35 @@ public function getAddNewAttributeButton($dataProvider = '')
4343
$attributeCreate = $this->getLayout()->createBlock(
4444
\Magento\Backend\Block\Widget\Button::class
4545
);
46-
$attributeCreate->setDataAttribute(
47-
[
48-
'mage-init' => [
49-
'productAttributes' => [
50-
'dataProvider' => $dataProvider,
51-
'url' => $this->getUrl('catalog/product_attribute/new', [
52-
'store' => $this->registry->registry('current_product')->getStoreId(),
53-
'product_tab' => 'variations',
54-
'popup' => 1,
55-
'_query' => [
56-
'attribute' => [
57-
'is_global' => 1,
58-
'frontend_input' => 'select',
46+
if ($attributeCreate->getAuthorization()->isAllowed('Magento_Catalog::attributes_attributes')) {
47+
$attributeCreate->setDataAttribute(
48+
[
49+
'mage-init' => [
50+
'productAttributes' => [
51+
'dataProvider' => $dataProvider,
52+
'url' => $this->getUrl('catalog/product_attribute/new', [
53+
'store' => $this->coreRegistry->registry('current_product')->getStoreId(),
54+
'product_tab' => 'variations',
55+
'popup' => 1,
56+
'_query' => [
57+
'attribute' => [
58+
'is_global' => 1,
59+
'frontend_input' => 'select',
60+
],
5961
],
60-
],
61-
]),
62+
]),
63+
],
6264
],
63-
],
64-
]
65-
)->setType(
66-
'button'
67-
)->setLabel(
68-
__('Create New Attribute')
69-
);
70-
return $attributeCreate->toHtml();
65+
]
66+
)->setType(
67+
'button'
68+
)->setLabel(
69+
__('Create New Attribute')
70+
);
71+
return $attributeCreate->toHtml();
72+
} else {
73+
return '';
74+
}
7175
}
7276

7377
/**

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/CreateOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class CreateOptions extends Action
1616
*
1717
* @see _isAllowed()
1818
*/
19-
const ADMIN_RESOURCE = 'Magento_Catalog::attributes_attributes';
19+
const ADMIN_RESOURCE = 'Magento_Catalog::products';
2020

2121
/**
2222
* @var \Magento\Framework\Json\Helper\Data

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/GetAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class GetAttributes extends Action
1616
*
1717
* @see _isAllowed()
1818
*/
19-
const ADMIN_RESOURCE = 'Magento_Catalog::attributes_attributes';
19+
const ADMIN_RESOURCE = 'Magento_Catalog::products';
2020

2121
/**
2222
* Store manager

app/code/Magento/ConfigurableProduct/Controller/Adminhtml/Product/Attribute/SuggestConfigurableAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class SuggestConfigurableAttributes extends Action
1616
*
1717
* @see _isAllowed()
1818
*/
19-
const ADMIN_RESOURCE = 'Magento_Catalog::attributes_attributes';
19+
const ADMIN_RESOURCE = 'Magento_Catalog::products';
2020

2121
/**
2222
* @var \Magento\ConfigurableProduct\Model\SuggestedAttributeList
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ConfigurableProduct\Test\Unit\Block\Adminhtml\Product\Steps;
7+
8+
use Magento\ConfigurableProduct\Block\Adminhtml\Product\Steps\SelectAttributes;
9+
use Magento\Framework\View\Element\Template\Context;
10+
use Magento\Framework\Registry;
11+
use Magento\Backend\Block\Widget\Button;
12+
use Magento\Framework\View\LayoutInterface;
13+
use Magento\Catalog\Api\Data\ProductInterface;
14+
use Magento\Framework\UrlInterface;
15+
16+
class SelectAttributesTest extends \PHPUnit_Framework_TestCase
17+
{
18+
/**
19+
* @var SelectAttributes
20+
*/
21+
private $selectAttributes;
22+
23+
/**
24+
* @var Context|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
private $contextMock;
27+
28+
/**
29+
* @var Registry|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $registryMock;
32+
33+
/**
34+
* @var Button|\PHPUnit_Framework_MockObject_MockObject
35+
*/
36+
private $buttonMock;
37+
38+
/**
39+
* @var LayoutInterface|\PHPUnit_Framework_MockObject_MockObject
40+
*/
41+
private $layoutMock;
42+
43+
/**
44+
* @var UrlInterface|\PHPUnit_Framework_MockObject_MockObject
45+
*/
46+
private $urlBuilderMock;
47+
48+
/**
49+
* {@inheritDoc}
50+
*/
51+
protected function setUp()
52+
{
53+
$this->contextMock = $this->getMockBuilder(Context::class)
54+
->disableOriginalConstructor()
55+
->getMock();
56+
$this->registryMock = $this->getMockBuilder(Registry::class)
57+
->getMock();
58+
$this->buttonMock = $this->getMockBuilder(Button::class)
59+
->disableOriginalConstructor()
60+
->setMethods(['isAllowed', 'getAuthorization', 'toHtml'])
61+
->getMock();
62+
$this->layoutMock = $this->getMockBuilder(LayoutInterface::class)
63+
->disableOriginalConstructor()
64+
->getMock();
65+
$this->urlBuilderMock = $this->getMockBuilder(UrlInterface::class)
66+
->disableOriginalConstructor()
67+
->getMock();
68+
69+
$this->contextMock->expects($this->any())
70+
->method('getLayout')
71+
->willReturn($this->layoutMock);
72+
$this->contextMock->expects($this->any())
73+
->method('getUrlBuilder')
74+
->willReturn($this->urlBuilderMock);
75+
76+
$this->selectAttributes = new SelectAttributes(
77+
$this->contextMock,
78+
$this->registryMock
79+
);
80+
}
81+
82+
/**
83+
* @param bool $isAllowed
84+
* @param string $result
85+
*
86+
* @dataProvider attributesDataProvider
87+
*
88+
* @return void
89+
*/
90+
public function testGetAddNewAttributeButton($isAllowed, $result)
91+
{
92+
$productMock = $this->getMockBuilder(ProductInterface::class)
93+
->setMethods(['getStoreId'])
94+
->getMockForAbstractClass();
95+
$this->registryMock->expects($this->any())
96+
->method('registry')
97+
->with('current_product')
98+
->willReturn($productMock);
99+
$this->buttonMock->expects($this->any())
100+
->method('toHtml')
101+
->willReturn($result);
102+
103+
$this->layoutMock->expects($this->once())
104+
->method('createBlock')
105+
->willReturn($this->buttonMock);
106+
$this->buttonMock->expects($this->once())
107+
->method('getAuthorization')
108+
->willReturnSelf();
109+
$this->buttonMock->expects($this->once())
110+
->method('isAllowed')
111+
->with('Magento_Catalog::attributes_attributes')
112+
->willReturn($isAllowed);
113+
114+
$this->assertEquals($result, $this->selectAttributes->getAddNewAttributeButton());
115+
}
116+
117+
public function attributesDataProvider()
118+
{
119+
return [
120+
[false, ''],
121+
[true, 'attribute html']
122+
];
123+
}
124+
}

app/code/Magento/Customer/Controller/Account/ResetPasswordPost.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Magento\Customer\Model\Session;
1212
use Magento\Framework\App\Action\Context;
1313
use Magento\Framework\Exception\InputException;
14+
use Magento\Customer\Model\Customer\CredentialsValidator;
15+
use Magento\Framework\App\ObjectManager;
1416

1517
class ResetPasswordPost extends \Magento\Customer\Controller\AbstractAccount
1618
{
@@ -25,21 +27,30 @@ class ResetPasswordPost extends \Magento\Customer\Controller\AbstractAccount
2527
*/
2628
protected $session;
2729

30+
/**
31+
* @var CredentialsValidator
32+
*/
33+
private $credentialsValidator;
34+
2835
/**
2936
* @param Context $context
3037
* @param Session $customerSession
3138
* @param AccountManagementInterface $accountManagement
3239
* @param CustomerRepositoryInterface $customerRepository
40+
* @param CredentialsValidator|null $credentialsValidator
3341
*/
3442
public function __construct(
3543
Context $context,
3644
Session $customerSession,
3745
AccountManagementInterface $accountManagement,
38-
CustomerRepositoryInterface $customerRepository
46+
CustomerRepositoryInterface $customerRepository,
47+
CredentialsValidator $credentialsValidator = null
3948
) {
4049
$this->session = $customerSession;
4150
$this->accountManagement = $accountManagement;
4251
$this->customerRepository = $customerRepository;
52+
$this->credentialsValidator = $credentialsValidator ?: ObjectManager::getInstance()
53+
->get(CredentialsValidator::class);
4354
parent::__construct($context);
4455
}
4556

@@ -72,6 +83,7 @@ public function execute()
7283

7384
try {
7485
$customerEmail = $this->customerRepository->getById($customerId)->getEmail();
86+
$this->credentialsValidator->checkPasswordDifferentFromEmail($customerEmail, $password);
7587
$this->accountManagement->resetPassword($customerEmail, $resetPasswordToken, $password);
7688
$this->session->unsRpToken();
7789
$this->session->unsRpCustomerId();

0 commit comments

Comments
 (0)