-
Notifications
You must be signed in to change notification settings - Fork 9.4k
#11825: Generate new FormKey and replace for oldRequestParams Wishlist #12038
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
Conversation
Can you check @vkublytskyi . Thanks! |
*/ | ||
public function __construct(CookieFormKey $cookieFormKey, DataFormKey $dataFormKey) | ||
public function __construct(CookieFormKey $cookieFormKey, DataFormKey $dataFormKey, Session $customerSession) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not backward compatible change. Could you add $customerSession as optional parameter with fallback to retrieving this object via ObjectManger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ihor-sviziev I will work after mm17es in this fix.
$this->cookieFormKey->delete(); | ||
$this->dataFormKey->set(null); | ||
|
||
$beforeParams = $this->customerSession->getBeforeRequestParams(); | ||
if ($beforeParams['form_key'] == $currentFormKey) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add check that $beforeParams['form_key'] is exist? $beforeParams might be empty array.
Also would be great to use strict equal === comparison instead of ==.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ihor-sviziev I will work after mm17es in this fix.
@ihor-sviziev Changes Made. Thanks for your comments |
@ihor-sviziev Observers and plugins do not follow this backward compatibility rule (as they must not be extended or called individually) and constructor may be changed. |
@osrecio tests failed as this fix introduces dependency for PageCache on Customer module. We should avoid this for bugfixes. Also we should avoid this as Customer module already has a dependency on PageCashe module and we must avoid circular dependencies. As a solution, I may suggest make a plugin on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review latest comments form @vkublytskyi
e4caf97
to
f6b052f
Compare
Hi @vkublytskyi I added a Plugin in Customer Module to make the same logic. |
@osrecio static test failed because of not used parameter. Please ignore it in the code. |
/** | ||
* @param FlushFormKey $subject | ||
* @param callable $proceed | ||
* @param $args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add @SuppressWarnings(PHPMD.UnusedFormalParameter)
to avoid static tests failure
80a93f2
to
60a15b8
Compare
60a15b8
to
03ac5b5
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added unit test contains an error
->method('setBeforeRequestParams') | ||
->with($beforeParams); | ||
|
||
$plugin->aroundExecute($observer, $this->closure, $observer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line contains an error. $observer
is instance of Magento\PageCache\Observer\FlushFormKey
which is child of \Magento\Framework\Event\ObserverInterface
. aroundExecute
method should mutch signature of Magento\PageCache\Observer\FlushFormKey::execute
so last parameter should be instance of Magento\Framework\Event\Observer
which is child of Magento\Framework\DataObject
and NOT related to Magento\Framework\Event\ObserverInterface
.
To catch such kind of an issue I propose you to add logic to closure and invoke FlushFormKey ::execute
inside.
Thanks @vkublytskyi I was going to work on the changes this weekend. Busy Week |
…dRequestParams Wishlist magento#12038 - fixed unit test
fb54dfa
to
04a1c77
Compare
@osrecio I will resolve minor fixes to free your time for more interesting things) |
Generate new FormKey afterLogin and set to the beforeRequest(Wishlist)
Description
Generate new FormKey afterLogin and set to the beforeRequest(Wishlist)
Fixed Issues (if relevant)
Manual testing scenarios
Contribution checklist