-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#19345: Incorrect caching subscription status in newsletter plugin.
- Loading branch information
1 parent
6df702e
commit c6e170e
Showing
3 changed files
with
95 additions
and
19 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
app/code/Magento/Newsletter/Model/CustomerSubscriberCache.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Newsletter\Model; | ||
|
||
/** | ||
* This service provides caching Subscriber by Customer id. | ||
*/ | ||
class CustomerSubscriberCache | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $customerSubscriber = []; | ||
|
||
/** | ||
* Get Subscriber from cache by Customer id. | ||
* | ||
* @param int $customerId | ||
* @return Subscriber|null | ||
*/ | ||
public function getCustomerSubscriber(int $customerId): ?Subscriber | ||
{ | ||
$subscriber = null; | ||
if (isset($this->customerSubscriber[$customerId])) { | ||
$subscriber = $this->customerSubscriber[$customerId]; | ||
} | ||
|
||
return $subscriber; | ||
} | ||
|
||
/** | ||
* Set Subscriber to cache by Customer id. | ||
* | ||
* @param int $customerId | ||
* @param Subscriber|null $subscriber | ||
*/ | ||
public function setCustomerSubscriber(int $customerId, ?Subscriber $subscriber): void | ||
{ | ||
$this->customerSubscriber[$customerId] = $subscriber; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters