-
Notifications
You must be signed in to change notification settings - Fork 9.4k
magento/magento2#39905 Product Removed on Mobile Still Appears in Web's Mini Compare Section Until Re-login #40023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
magento-devops-reposync-svc
merged 13 commits into
magento:2.4-develop
from
KrasnoshchokBohdan:fix-for-issue-39905
Nov 4, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
09eb72d
magento/magento2#39905 Product Removed on Mobile Still Appears in Web…
KrasnoshchokBohdan 7b8032d
Merge branch '2.4-develop' into fix-for-issue-39905
KrasnoshchokBohdan 707be0d
magento/magento2#39905 Product Removed on Mobile Still Appears in Web…
KrasnoshchokBohdan ccda198
Merge branch '2.4-develop' into fix-for-issue-39905
KrasnoshchokBohdan a70613e
Merge branch '2.4-develop' into fix-for-issue-39905
KrasnoshchokBohdan c14fa3f
magento/magento2#39905 Product Removed on Mobile Still Appears in Web…
KrasnoshchokBohdan 3220e13
magento/magento2#39905 Product Removed on Mobile Still Appears in Web…
KrasnoshchokBohdan c94057e
Merge branch '2.4-develop' into fix-for-issue-39905
KrasnoshchokBohdan 4582620
Merge branch '2.4-develop' into fix-for-issue-39905
engcom-Hotel 402ce4f
Merge branch '2.4-develop' into fix-for-issue-39905
KrasnoshchokBohdan c51817f
magento/magento2#39905 Product Removed on Mobile Still Appears in Web…
KrasnoshchokBohdan 450ce29
Merge branch '2.4-develop' into fix-for-issue-39905
engcom-Hotel b0c0764
Merge branch '2.4-develop' into fix-for-issue-39905
engcom-Bravo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
89 changes: 89 additions & 0 deletions
89
app/code/Magento/CompareListGraphQl/Model/Service/CompareCookieManager.php
This file contains hidden or 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,89 @@ | ||
| <?php | ||
| /** | ||
| * Copyright 2025 Adobe | ||
| * All Rights Reserved. | ||
| */ | ||
| declare(strict_types=1); | ||
|
|
||
| namespace Magento\CompareListGraphQl\Model\Service; | ||
|
|
||
| use Exception; | ||
| use Magento\Framework\Stdlib\CookieManagerInterface; | ||
| use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory; | ||
| use Magento\Framework\Exception\InputException; | ||
| use Magento\Framework\Stdlib\Cookie\FailureToSendException; | ||
| use Magento\Framework\Stdlib\Cookie\CookieSizeLimitReachedException; | ||
| use Psr\Log\LoggerInterface; | ||
|
|
||
| /** | ||
| * Service for managing compare list cookies | ||
| * | ||
| * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) | ||
| */ | ||
| class CompareCookieManager | ||
| { | ||
| /** | ||
| * Name of cookie that holds compare products section data | ||
| */ | ||
| public const COOKIE_COMPARE_PRODUCTS = 'section_data_ids'; | ||
|
|
||
| /** | ||
| * The path for which the cookie will be available | ||
| */ | ||
| public const COOKIE_PATH = '/'; | ||
|
|
||
| /** | ||
| * Cookie lifetime value in seconds (86400 = 24 hours) | ||
| */ | ||
| public const COOKIE_LIFETIME = 86400; | ||
|
|
||
| /** | ||
| * @param CookieManagerInterface $cookieManager | ||
| * @param CookieMetadataFactory $cookieMetadataFactory | ||
| * @param LoggerInterface $logger | ||
| */ | ||
| public function __construct( | ||
| private readonly CookieManagerInterface $cookieManager, | ||
| private readonly CookieMetadataFactory $cookieMetadataFactory, | ||
| private readonly LoggerInterface $logger | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * Marks compare products section as invalid by updating the cookie value | ||
| * | ||
| * @return void | ||
| */ | ||
| public function invalidate(): void | ||
| { | ||
| try { | ||
| $cookieValue = json_encode(['compare-products' => time()]); | ||
| $this->setCookie($cookieValue); | ||
| } catch (Exception $e) { | ||
| $this->logger->error('Error invalidating compare products cookie: ' . $e->getMessage()); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Set compare products cookie | ||
| * | ||
| * @param string $value | ||
| * @return void | ||
| * @throws InputException | ||
| * @throws CookieSizeLimitReachedException | ||
| * @throws FailureToSendException | ||
| */ | ||
| private function setCookie(string $value): void | ||
| { | ||
| $publicCookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata() | ||
| ->setDuration(self::COOKIE_LIFETIME) | ||
| ->setPath(self::COOKIE_PATH) | ||
| ->setHttpOnly(false); | ||
|
|
||
| $this->cookieManager->setPublicCookie( | ||
| self::COOKIE_COMPARE_PRODUCTS, | ||
| $value, | ||
| $publicCookieMetadata | ||
| ); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.