Skip to content
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

Fix for the issue #24547 Magento\Customer\Model\Account\Redirect::setRedirectCookie() not properly working #24612

Merged
merged 19 commits into from
Feb 20, 2020

Conversation

sashas777
Copy link
Contributor

@sashas777 sashas777 commented Sep 15, 2019

Description (*)

Added metadata to the setRedirectCookie and clearRedirectCookie functions.

Fixed Issues (if relevant)

  1. Magento\Customer\Model\Account\Redirect::setRedirectCookie() not properly working #24547: Magento\Customer\Model\Account\Redirect::setRedirectCookie() not properly working

Manual testing scenarios (*)

  1. Call method Magento\Customer\Model\Account\Redirect::setRedirectCookie()

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Sep 15, 2019

Hi @sashas777. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.3-develop instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Guide documentation.

…ct::setRedirectCookie() not properly working
@sashas777
Copy link
Contributor Author

sashas777 commented Sep 18, 2019

@paliarush can you advise how to avoid these errors, please?

/var/www/html/app/code/Magento/Customer/Model/Account/Redirect.php:28	The class Magento\Customer\Model\Account\Redirect uses sessions or cookies while not being a part of HTML Presentation layer
/var/www/html/app/code/Magento/Customer/Model/Account/Redirect.php:103	The method __construct has 10 parameters. Consider reducing the number of parameters to less than 10.
/var/www/html/app/code/Magento/Customer/Model/RedirectCookieManager.php:14	The class Magento\Customer\Model\RedirectCookieManager uses sessions or cookies while not being a part of HTML Presentation layer

Failed asserting that 2 matches expected 0.```

@drpayyne
Copy link
Contributor

drpayyne commented Oct 4, 2019

Hello @sashas777

The method __construct has 10 parameters. Consider reducing the number of parameters to less than 10

is common and can be suppressed by adding @SuppressWarnings(PHPMD.ExcessiveParameterList) to the method's PHPDoc Blocks.

The class Magento\Customer\Model\RedirectCookieManager uses sessions or cookies while not being a part of HTML Presentation layer

can be suppressed by adding @SuppressWarnings(PHPMD.CookieAndSessionMisuse) to both the classes' PHPDoc Blocks.

Although, changing the constructor signature isn't backward compatible. Please refer to Backward compatible development for your issues.

@sashas777 sashas777 requested a review from orlangur October 8, 2019 20:27
@josefbehr josefbehr self-assigned this Oct 21, 2019
@sidolov sidolov changed the base branch from 2.3-develop to 2.4-develop December 5, 2019 17:19
*/
public function setRedirectCookie($route, StoreInterface $store)
{
$cookieMetadata = $this->cookieMetadataFactory->createPublicCookieMetadata()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Public cookie metadata is used. What will be the behavior and is it appropriate in the case if connection is secured?

@dyushkin
Copy link
Contributor

dyushkin commented Feb 6, 2020

Hello @sashas777!
Thank you for your contribution.
Methods getCookieManager, setCookieManager, getRedirectCookie, setRedirectCookie, clearRedirectCookie provided in Magento\Customer\Model\Account\Redirect class looks very legacy, and created with one purpose - to pass login_redirect cookie from Magento/Checkout/view/frontend/web/js/sidebar.js to backend for processing, and creating a redirect url.
Considering this, it is not much of use cases for these public methods, to create the implementation with its own single class. Can you please tag public methods I mentioned before as deprecated with the proper comment, and remove the Magento/Customer/Model/RedirectCookieManager. Please recheck suppress warnings are necessary.
Thank you,

…ookieManager, setCookieManager, getRedirectCookie, setRedirectCookie, clearRedirectCookie
…ookieManager, setCookieManager, getRedirectCookie, setRedirectCookie, clearRedirectCookie
@sashas777
Copy link
Contributor Author

@dyushkin Updated. Does it look correct now?

…ookieManager, setCookieManager, getRedirectCookie, setRedirectCookie, clearRedirectCookie
@dyushkin
Copy link
Contributor

dyushkin commented Feb 7, 2020

@sashas777, thank you for quick updates, looks fine for me.

@dyushkin dyushkin assigned dyushkin and unassigned dyushkin Feb 10, 2020
@engcom-Golf engcom-Golf self-assigned this Feb 11, 2020
@engcom-Golf engcom-Golf added the Auto-Tests: Covered All changes in Pull Request is covered by auto-tests label Feb 12, 2020
@engcom-Golf
Copy link
Contributor

@magento run all tests

@engcom-Golf engcom-Golf requested a review from dyushkin February 12, 2020 14:59
@magento-engcom-team
Copy link
Contributor

Hi @lenaorobei, thank you for the review.
ENGCOM-6891 has been created to process this Pull Request

Copy link
Contributor

@dyushkin dyushkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes are correct.

@engcom-Delta
Copy link
Contributor

✔️ QA passed

@m2-assistant
Copy link

m2-assistant bot commented Feb 20, 2020

Hi @sashas777, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@sdzhepa sdzhepa mentioned this pull request May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.