Skip to content

Commit 84e7c86

Browse files
Merge pull request #1654 from magento-engcom/develop-prs
[EngCom] Public Pull Requests - develop - MAGETWO-83154: [2.3-develop] Order grid - Sort by Purchase Date Desc by default #11931 - MAGETWO-83101: [Backport 2.3-develop] #8236 FIX CMS blocks #11805 - MAGETWO-83092: Remove unneeded, also mistyped, saveHandler from CatalogSearch indexer declaration #11626 - MAGETWO-83091: Remove "Undefined fields" from under lib folder #11662 - MAGETWO-83083: 10195: Order relation child is not set during edit operation #11909 - MAGETWO-82998: [2.3-develop] X-Magento-Tags header containing whitespaces causes exception #11849 - MAGETWO-82633: #11409: Too many password reset requests even when disabled in settings #11434
2 parents 8462688 + a7c9272 commit 84e7c86

File tree

41 files changed

+339
-100
lines changed

Some content is hidden

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

41 files changed

+339
-100
lines changed

app/code/Magento/CatalogSearch/etc/indexer.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
<indexer id="catalogsearch_fulltext" view_id="catalogsearch_fulltext" class="Magento\CatalogSearch\Model\Indexer\Fulltext">
1010
<title translate="true">Catalog Search</title>
1111
<description translate="true">Rebuild Catalog product fulltext search index</description>
12-
13-
<saveHandler class="Magento\CatalogSearch\Model\Indexer\IndexHandler" />
1412
<structure class="Magento\CatalogSearch\Model\Indexer\IndexStructure" />
1513
</indexer>
1614
</config>

app/code/Magento/Cms/Model/ResourceModel/Block.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ public function getIsUniqueBlockToStores(AbstractModel $object)
183183
$entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class);
184184
$linkField = $entityMetadata->getLinkField();
185185

186-
if ($this->_storeManager->hasSingleStore()) {
186+
if ($this->_storeManager->isSingleStoreMode()) {
187187
$stores = [Store::DEFAULT_STORE_ID];
188188
} else {
189-
$stores = (array)$object->getData('stores');
189+
$stores = (array)$object->getData('store_id');
190190
}
191191

192192
$select = $this->getConnection()->select()
@@ -230,7 +230,7 @@ public function lookupStoreIds($id)
230230
'cbs.' . $linkField . ' = cb.' . $linkField,
231231
[]
232232
)
233-
->where('cb.' . $entityMetadata->getIdentifierField() . ' = :block_id');
233+
->where('cb.' . $entityMetadata->getIdentifierField() . ' = :block_id');
234234

235235
return $connection->fetchCol($select, ['block_id' => (int)$id]);
236236
}

app/code/Magento/Sales/Model/AdminOrder/Create.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,7 @@ public function createOrder()
19071907
$oldOrder = $this->getSession()->getOrder();
19081908
$oldOrder->setRelationChildId($order->getId());
19091909
$oldOrder->setRelationChildRealId($order->getIncrementId());
1910+
$oldOrder->save();
19101911
$this->orderManagement->cancel($oldOrder->getEntityId());
19111912
$order->save();
19121913
}

app/code/Magento/Sales/view/adminhtml/ui_component/sales_order_grid.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@
139139
<settings>
140140
<filter>text</filter>
141141
<label translate="true">ID</label>
142-
<sorting>desc</sorting>
143142
</settings>
144143
</column>
145144
<column name="store_id" class="Magento\Store\Ui\Component\Listing\Column\Store">
@@ -154,6 +153,7 @@
154153
<filter>dateRange</filter>
155154
<dataType>date</dataType>
156155
<label translate="true">Purchase Date</label>
156+
<sorting>desc</sorting>
157157
</settings>
158158
</column>
159159
<column name="billing_name">

app/code/Magento/Security/Model/Config.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ class Config implements ConfigInterface
2424
*/
2525
const XML_PATH_ADMIN_AREA = 'admin/security/';
2626

27+
/**
28+
* Configuration path to frontend area
29+
*/
30+
const XML_PATH_FRONTEND_AREA = 'customer/password/';
31+
2732
/**
2833
* Configuration path to fronted area
34+
* @deprecated
35+
* @see \Magento\Security\Model\Config::XML_PATH_FRONTEND_AREA
2936
*/
30-
const XML_PATH_FRONTED_AREA = 'customer/password/';
37+
const XML_PATH_FRONTED_AREA = self::XML_PATH_FRONTEND_AREA;
3138

3239
/**
3340
* Configuration path to admin account sharing
@@ -134,7 +141,7 @@ protected function getXmlPathPrefix()
134141
if ($this->scope->getCurrentScope() == \Magento\Framework\App\Area::AREA_ADMINHTML) {
135142
return self::XML_PATH_ADMIN_AREA;
136143
}
137-
return self::XML_PATH_FRONTED_AREA;
144+
return self::XML_PATH_FRONTEND_AREA;
138145
}
139146

140147
/**

app/code/Magento/Security/Model/Plugin/AccountManagement.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
*/
66
namespace Magento\Security\Model\Plugin;
77

8-
use Magento\Security\Model\SecurityManager;
98
use Magento\Customer\Model\AccountManagement as AccountManagementOriginal;
9+
use Magento\Framework\App\ObjectManager;
10+
use Magento\Framework\Config\ScopeInterface;
1011
use Magento\Framework\Exception\SecurityViolationException;
1112
use Magento\Security\Model\PasswordResetRequestEvent;
13+
use Magento\Security\Model\SecurityManager;
1214

1315
/**
1416
* Magento\Customer\Model\AccountManagement decorator
@@ -30,21 +32,29 @@ class AccountManagement
3032
*/
3133
protected $passwordRequestEvent;
3234

35+
/**
36+
* @var ScopeInterface
37+
*/
38+
private $scope;
39+
3340
/**
3441
* AccountManagement constructor.
3542
*
3643
* @param \Magento\Framework\App\RequestInterface $request
3744
* @param SecurityManager $securityManager
3845
* @param int $passwordRequestEvent
46+
* @param ScopeInterface $scope
3947
*/
4048
public function __construct(
4149
\Magento\Framework\App\RequestInterface $request,
4250
\Magento\Security\Model\SecurityManager $securityManager,
43-
$passwordRequestEvent = PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST
51+
$passwordRequestEvent = PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST,
52+
ScopeInterface $scope = null
4453
) {
4554
$this->request = $request;
4655
$this->securityManager = $securityManager;
4756
$this->passwordRequestEvent = $passwordRequestEvent;
57+
$this->scope = $scope ?: ObjectManager::getInstance()->get(ScopeInterface::class);
4858
}
4959

5060
/**
@@ -63,10 +73,14 @@ public function beforeInitiatePasswordReset(
6373
$template,
6474
$websiteId = null
6575
) {
66-
$this->securityManager->performSecurityCheck(
67-
$this->passwordRequestEvent,
68-
$email
69-
);
76+
if ($this->scope->getCurrentScope() == \Magento\Framework\App\Area::AREA_FRONTEND
77+
|| $this->passwordRequestEvent == PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST) {
78+
$this->securityManager->performSecurityCheck(
79+
$this->passwordRequestEvent,
80+
$email
81+
);
82+
}
83+
7084
return [$email, $template, $websiteId];
7185
}
7286
}

app/code/Magento/Security/Test/Unit/Model/ConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected function getXmlPathPrefix($scope)
167167
if ($scope == \Magento\Framework\App\Area::AREA_ADMINHTML) {
168168
return \Magento\Security\Model\Config::XML_PATH_ADMIN_AREA;
169169
}
170-
return \Magento\Security\Model\Config::XML_PATH_FRONTED_AREA;
170+
return \Magento\Security\Model\Config::XML_PATH_FRONTEND_AREA;
171171
}
172172

173173
/**

app/code/Magento/Security/Test/Unit/Model/Plugin/AccountManagementTest.php

Lines changed: 48 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
namespace Magento\Security\Test\Unit\Model\Plugin;
88

9+
use Magento\Customer\Model\AccountManagement;
10+
use Magento\Framework\App\Area;
11+
use Magento\Framework\Config\ScopeInterface;
912
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
13+
use Magento\Security\Model\PasswordResetRequestEvent;
1014

1115
/**
1216
* Test class for \Magento\Security\Model\Plugin\AccountManagement testing
@@ -19,20 +23,25 @@ class AccountManagementTest extends \PHPUnit\Framework\TestCase
1923
protected $model;
2024

2125
/**
22-
* @var \Magento\Framework\App\RequestInterface
26+
* @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
2327
*/
2428
protected $request;
2529

2630
/**
27-
* @var \Magento\Security\Model\SecurityManager
31+
* @var \Magento\Security\Model\SecurityManager|\PHPUnit_Framework_MockObject_MockObject
2832
*/
2933
protected $securityManager;
3034

3135
/**
32-
* @var \Magento\Customer\Model\AccountManagement
36+
* @var AccountManagement|\PHPUnit_Framework_MockObject_MockObject
3337
*/
3438
protected $accountManagement;
3539

40+
/**
41+
* @var ScopeInterface|\PHPUnit_Framework_MockObject_MockObject
42+
*/
43+
private $scope;
44+
3645
/**
3746
* @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
3847
*/
@@ -53,28 +62,38 @@ public function setUp()
5362
['performSecurityCheck']
5463
);
5564

56-
$this->accountManagement = $this->createMock(\Magento\Customer\Model\AccountManagement::class);
65+
$this->accountManagement = $this->createMock(AccountManagement::class);
66+
$this->scope = $this->createMock(ScopeInterface::class);
67+
}
68+
69+
/**
70+
* @param $area
71+
* @param $passwordRequestEvent
72+
* @param $expectedTimes
73+
* @dataProvider beforeInitiatePasswordResetDataProvider
74+
*/
75+
public function testBeforeInitiatePasswordReset($area, $passwordRequestEvent, $expectedTimes)
76+
{
77+
$email = 'test@example.com';
78+
$template = AccountManagement::EMAIL_RESET;
5779

5880
$this->model = $this->objectManager->getObject(
5981
\Magento\Security\Model\Plugin\AccountManagement::class,
6082
[
83+
'passwordRequestEvent' => $passwordRequestEvent,
6184
'request' => $this->request,
62-
'securityManager' => $this->securityManager
85+
'securityManager' => $this->securityManager,
86+
'scope' => $this->scope
6387
]
6488
);
65-
}
6689

67-
/**
68-
* @return void
69-
*/
70-
public function testBeforeInitiatePasswordReset()
71-
{
72-
$email = 'test@example.com';
73-
$template = \Magento\Customer\Model\AccountManagement::EMAIL_RESET;
90+
$this->scope->expects($this->once())
91+
->method('getCurrentScope')
92+
->willReturn($area);
7493

75-
$this->securityManager->expects($this->once())
94+
$this->securityManager->expects($this->exactly($expectedTimes))
7695
->method('performSecurityCheck')
77-
->with(\Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, $email)
96+
->with($passwordRequestEvent, $email)
7897
->willReturnSelf();
7998

8099
$this->model->beforeInitiatePasswordReset(
@@ -83,4 +102,18 @@ public function testBeforeInitiatePasswordReset()
83102
$template
84103
);
85104
}
105+
106+
/**
107+
* @return array
108+
*/
109+
public function beforeInitiatePasswordResetDataProvider()
110+
{
111+
return [
112+
[Area::AREA_ADMINHTML, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 0],
113+
[Area::AREA_ADMINHTML, PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, 1],
114+
[Area::AREA_FRONTEND, PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST, 1],
115+
// This should never happen, but let's cover it with tests
116+
[Area::AREA_FRONTEND, PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST, 1],
117+
];
118+
}
86119
}

app/code/Magento/Security/etc/adminhtml/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</type>
1818
<type name="Magento\Security\Model\Plugin\AccountManagement">
1919
<arguments>
20-
<argument name="passwordRequestEvent" xsi:type="const">Magento\Security\Model\PasswordResetRequestEvent::ADMIN_PASSWORD_RESET_REQUEST</argument>
20+
<argument name="passwordRequestEvent" xsi:type="const">Magento\Security\Model\PasswordResetRequestEvent::CUSTOMER_PASSWORD_RESET_REQUEST</argument>
2121
</arguments>
2222
</type>
2323
<type name="Magento\Security\Model\SecurityManager">

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,12 @@
88
use Magento\Customer\Api\Data\CustomerInterface as Customer;
99
use Magento\Customer\Model\AccountManagement;
1010
use Magento\Framework\Exception\InputException;
11-
use Magento\Framework\Exception\NoSuchEntityException;
11+
use Magento\Framework\Webapi\Exception as HTTPExceptionCodes;
12+
use Magento\Newsletter\Model\Subscriber;
13+
use Magento\Security\Model\Config;
1214
use Magento\TestFramework\Helper\Bootstrap;
1315
use Magento\TestFramework\Helper\Customer as CustomerHelper;
1416
use Magento\TestFramework\TestCase\WebapiAbstract;
15-
use Magento\Framework\Webapi\Exception as HTTPExceptionCodes;
16-
use Magento\Security\Model\Config;
17-
use Magento\Newsletter\Model\Plugin\CustomerPlugin;
18-
use Magento\Framework\Webapi\Rest\Request as RestRequest;
19-
use Magento\Newsletter\Model\Subscriber;
20-
use Magento\Customer\Model\Data\Customer as CustomerData;
2117

2218
/**
2319
* Test class for Magento\Customer\Api\AccountManagementInterface
@@ -112,16 +108,16 @@ public function setUp()
112108
$this->initSubscriber();
113109

114110
if ($this->config->getConfigDataValue(
115-
Config::XML_PATH_FRONTED_AREA .
111+
Config::XML_PATH_FRONTEND_AREA .
116112
Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE
117113
) != 0) {
118114
$this->configValue = $this->config
119115
->getConfigDataValue(
120-
Config::XML_PATH_FRONTED_AREA .
116+
Config::XML_PATH_FRONTEND_AREA .
121117
Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE
122118
);
123119
$this->config->setDataByPath(
124-
Config::XML_PATH_FRONTED_AREA . Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE,
120+
Config::XML_PATH_FRONTEND_AREA . Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE,
125121
0
126122
);
127123
$this->config->save();
@@ -150,7 +146,7 @@ public function tearDown()
150146
}
151147
}
152148
$this->config->setDataByPath(
153-
Config::XML_PATH_FRONTED_AREA . Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE,
149+
Config::XML_PATH_FRONTEND_AREA . Config::XML_PATH_PASSWORD_RESET_PROTECTION_TYPE,
154150
$this->configValue
155151
);
156152
$this->config->save();

0 commit comments

Comments
 (0)