Skip to content

Commit 7bb6f02

Browse files
committed
Fix customer route compability with AccountInterface
1 parent 79040b7 commit 7bb6f02

File tree

4 files changed

+8
-33
lines changed

4 files changed

+8
-33
lines changed

Api/Data/EraseEntityInterface.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,7 @@ public function setEraseId(int $eraseId): EraseEntityInterface;
4747

4848
public function getEntityId(): int;
4949

50-
/**
51-
* Set the entity ID
52-
*
53-
* @param int $entityId
54-
* @return EraseEntityInterface
55-
* @todo force type in php7.4
56-
*/
57-
public function setEntityId($entityId): EraseEntityInterface;
50+
public function setEntityId(int $entityId): EraseEntityInterface;
5851

5952
public function getEntityType(): string;
6053

Api/Data/ExportEntityInterface.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,7 @@ public function setExportId(int $exportId): ExportEntityInterface;
3030

3131
public function getEntityId(): int;
3232

33-
/**
34-
* Set the entity ID
35-
*
36-
* @param int $entityId
37-
* @return ExportEntityInterface
38-
* @todo force type in php7.4
39-
*/
40-
public function setEntityId($entityId): ExportEntityInterface;
33+
public function setEntityId(int $entityId): ExportEntityInterface;
4134

4235
public function getEntityType(): string;
4336

Controller/AbstractAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(
2626
protected Config $config
2727
) {}
2828

29-
public function execute(): ResultInterface|ResponseInterface
29+
public function execute()
3030
{
3131
return $this->isAllowed() ? $this->executeAction() : $this->forwardNoRoute();
3232
}

Model/Customer/Anonymize/Processor/CustomerDataProcessor.php

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

88
namespace Opengento\Gdpr\Model\Customer\Anonymize\Processor;
99

10-
use DateTime;
1110
use Magento\Customer\Api\CustomerRepositoryInterface;
1211
use Magento\Customer\Api\Data\CustomerInterface;
1312
use Magento\Customer\Api\SessionCleanerInterface;
@@ -19,21 +18,14 @@
1918
use Magento\Framework\Exception\LocalizedException;
2019
use Magento\Framework\Exception\NoSuchEntityException;
2120
use Magento\Framework\Exception\State\InputMismatchException;
22-
use Magento\Framework\Stdlib\DateTime as DateTimeFormat;
21+
use Magento\Framework\Math\Random;
2322
use Magento\Sales\Api\Data\OrderInterface;
2423
use Magento\Sales\Api\Data\OrderSearchResultInterface;
2524
use Magento\Sales\Api\OrderRepositoryInterface;
2625
use Magento\Store\Model\ScopeInterface;
2726
use Opengento\Gdpr\Model\Customer\OrigDataRegistry;
2827
use Opengento\Gdpr\Service\Anonymize\AnonymizerInterface;
2928
use Opengento\Gdpr\Service\Erase\ProcessorInterface;
30-
use Random\RandomException;
31-
32-
use function random_int;
33-
use function sha1;
34-
use function uniqid;
35-
36-
use const PHP_INT_MAX;
3729

3830
class CustomerDataProcessor implements ProcessorInterface
3931
{
@@ -47,12 +39,12 @@ public function __construct(
4739
private CustomerRegistry $customerRegistry,
4840
private OrigDataRegistry $origDataRegistry,
4941
private SessionCleanerInterface $sessionCleaner,
50-
private ScopeConfigInterface $scopeConfig
42+
private ScopeConfigInterface $scopeConfig,
43+
private Random $random
5144
) {}
5245

5346
/**
5447
* @throws LocalizedException
55-
* @throws RandomException
5648
*/
5749
public function execute(int $entityId): bool
5850
{
@@ -72,7 +64,6 @@ public function execute(int $entityId): bool
7264
* @throws InputMismatchException
7365
* @throws LocalizedException
7466
* @throws NoSuchEntityException
75-
* @throws RandomException
7667
*/
7768
private function processCustomerData(int $customerId): void
7869
{
@@ -100,16 +91,14 @@ private function fetchOrdersList(CustomerInterface $customer): OrderSearchResult
10091
* @throws NoSuchEntityException
10192
* @throws InputException
10293
* @throws InputMismatchException
103-
* @throws RandomException
10494
*/
10595
private function anonymizeCustomer(CustomerInterface $customer): void
10696
{
10797
$this->customerRegistry->remove($customer->getId());
10898

10999
$secureData = $this->customerRegistry->retrieveSecureData($customer->getId());
110-
$dateTime = (new DateTime())->setTimestamp(PHP_INT_MAX);
111-
$secureData->setData('lock_expires', $dateTime->format(DateTimeFormat::DATETIME_PHP_FORMAT));
112-
$secureData->setPasswordHash(sha1(uniqid((string)random_int(), true)));
100+
$secureData->setData('lock_expires', '9999-12-31 23:59:59');
101+
$secureData->setPasswordHash($this->random->getUniqueHash());
113102

114103
$customer = $this->anonymizer->anonymize($customer);
115104
if ($customer instanceof DataObject) {

0 commit comments

Comments
 (0)