Skip to content

Commit 729650d

Browse files
authored
Merge pull request #4059 from magento-tango/tango-PR-04
TANGO PR 04
2 parents 1ffd8c5 + 489181f commit 729650d

File tree

5 files changed

+53
-25
lines changed

5 files changed

+53
-25
lines changed

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
624624
* @param string $rpToken
625625
* @throws ExpiredException
626626
* @throws NoSuchEntityException
627-
*
628627
* @return CustomerInterface
629628
* @throws LocalizedException
630629
*/
@@ -703,7 +702,12 @@ public function resetPassword($email, $resetToken, $newPassword)
703702
$customerSecure->setRpTokenCreatedAt(null);
704703
$customerSecure->setPasswordHash($this->createPasswordHash($newPassword));
705704
$this->destroyCustomerSessions($customer->getId());
706-
$this->sessionManager->destroy();
705+
if ($this->sessionManager->isSessionExists()) {
706+
//delete old session and move data to the new session
707+
//use this instead of $this->sessionManager->regenerateId because last one doesn't delete old session
708+
// phpcs:ignore Magento2.Functions.DiscouragedFunction
709+
session_regenerate_id(true);
710+
}
707711
$this->customerRepository->save($customer);
708712

709713
return true;
@@ -1564,6 +1568,7 @@ private function getEmailNotification()
15641568

15651569
/**
15661570
* Destroy all active customer sessions by customer id (current session will not be destroyed).
1571+
*
15671572
* Customer sessions which should be deleted are collecting from the "customer_visitor" table considering
15681573
* configured session lifetime.
15691574
*

app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,8 +1238,7 @@ public function testInitiatePasswordResetEmailReminder()
12381238

12391239
$storeId = 1;
12401240

1241-
mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
1242-
$hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
1241+
$hash = hash('sha256', microtime() . random_int(PHP_INT_MIN, PHP_INT_MAX));
12431242

12441243
$this->emailNotificationMock->expects($this->once())
12451244
->method('passwordReminder')
@@ -1263,8 +1262,7 @@ public function testInitiatePasswordResetEmailReset()
12631262
$templateIdentifier = 'Template Identifier';
12641263
$sender = 'Sender';
12651264

1266-
mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
1267-
$hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
1265+
$hash = hash('sha256', microtime() . random_int(PHP_INT_MIN, PHP_INT_MAX));
12681266

12691267
$this->emailNotificationMock->expects($this->once())
12701268
->method('passwordResetConfirmation')
@@ -1288,8 +1286,7 @@ public function testInitiatePasswordResetNoTemplate()
12881286
$templateIdentifier = 'Template Identifier';
12891287
$sender = 'Sender';
12901288

1291-
mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
1292-
$hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
1289+
$hash = hash('sha256', microtime() . random_int(PHP_INT_MIN, PHP_INT_MAX));
12931290

12941291
$this->prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash);
12951292

@@ -1610,7 +1607,7 @@ function ($string) {
16101607
$this->customerSecure->expects($this->once())->method('setRpTokenCreatedAt')->with(null);
16111608
$this->customerSecure->expects($this->any())->method('setPasswordHash')->willReturn(null);
16121609

1613-
$this->sessionManager->expects($this->atLeastOnce())->method('destroy');
1610+
$this->sessionManager->method('isSessionExists')->willReturn(false);
16141611
$this->sessionManager->expects($this->atLeastOnce())->method('getSessionId');
16151612
$visitor = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class)
16161613
->disableOriginalConstructor()

app/code/Magento/NewRelicReporting/Model/Module/Collect.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use Magento\NewRelicReporting\Model\Config;
1212
use Magento\NewRelicReporting\Model\Module;
1313

14+
/**
15+
* Class for collecting data for the report
16+
*/
1417
class Collect
1518
{
1619
/**
@@ -92,7 +95,6 @@ protected function getAllModules()
9295
* @param string $active
9396
* @param string $setupVersion
9497
* @param string $state
95-
*
9698
* @return array
9799
*/
98100
protected function getNewModuleChanges($moduleName, $active, $setupVersion, $state)
@@ -277,9 +279,7 @@ public function getModuleData($refresh = true)
277279
$changes = array_diff($module, $changeTest);
278280
$changesCleanArray = $this->getCleanChangesArray($changes);
279281

280-
if (count($changesCleanArray) > 0 ||
281-
($this->moduleManager->isOutputEnabled($changeTest['name']) &&
282-
$module['setup_version'] != null)) {
282+
if (!empty($changesCleanArray)) {
283283
$data = [
284284
'entity_id' => $changeTest['entity_id'],
285285
'name' => $changeTest['name'],

app/code/Magento/NewRelicReporting/Test/Unit/Model/Module/CollectTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,6 @@ public function testGetModuleDataWithoutRefresh()
162162
->method('getNames')
163163
->willReturn($enabledModulesMockArray);
164164

165-
$this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will(
166-
$this->returnValue(false)
167-
);
168-
169165
$this->assertInternalType(
170166
'array',
171167
$this->model->getModuleData()
@@ -256,10 +252,6 @@ public function testGetModuleDataRefresh($data)
256252
->method('getNames')
257253
->willReturn($enabledModulesMockArray);
258254

259-
$this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will(
260-
$this->returnValue(true)
261-
);
262-
263255
$this->assertInternalType(
264256
'array',
265257
$this->model->getModuleData()
@@ -350,10 +342,6 @@ public function testGetModuleDataRefreshOrStatement($data)
350342
->method('getNames')
351343
->willReturn($enabledModulesMockArray);
352344

353-
$this->moduleManagerMock->expects($this->any())->method('isOutputEnabled')->will(
354-
$this->returnValue(true)
355-
);
356-
357345
$this->assertInternalType(
358346
'array',
359347
$this->model->getModuleData()
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\NewRelicReporting\Model\Module;
7+
8+
use Magento\TestFramework\Helper\Bootstrap;
9+
use PHPUnit\Framework\TestCase;
10+
11+
/***
12+
* Class CollectTest
13+
*/
14+
class CollectTest extends TestCase
15+
{
16+
/**
17+
* @var Collect
18+
*/
19+
private $collect;
20+
21+
/**
22+
* @inheritDoc
23+
*/
24+
protected function setUp()
25+
{
26+
$this->collect = Bootstrap::getObjectManager()->create(Collect::class);
27+
}
28+
29+
/**
30+
* @return void
31+
*/
32+
public function testReport()
33+
{
34+
$this->collect->getModuleData();
35+
$moduleData = $this->collect->getModuleData();
36+
$this->assertEmpty($moduleData['changes']);
37+
}
38+
}

0 commit comments

Comments
 (0)