-
Notifications
You must be signed in to change notification settings - Fork 9.4k
[BACKPORT 2.2] [BUGFIX] check if currentStoreId === '' so report isn't generated if … #11915
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
[BACKPORT 2.2] [BUGFIX] check if currentStoreId === '' so report isn't generated if … #11915
Conversation
…url contains ___store= without storecode
There is also a problem with 1 of the integration tests.
|
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.
I have a couple of questions but nothing too major here.
|
||
return $store; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getCurrentStoreId() |
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.
Does this method need to be public? I can only see it being used currently inside this class.
} elseif (key_exists($storeId, $this->storeRepository->getList())) { | ||
$store = $this->storeRepository->get($storeId); | ||
} else { | ||
$store = $this->storeRepository->getById($this->getCurrentStoreId()); |
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.
I am a bit curious about this else. From what I can see $storeId
will be the result of $this->getCurrentStoreId()
. Is there any reason you have not just used $storeId
here rather than calling $this->getCurrentStoreId()
?
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.
Also from what I can see this thing could be done with:
if (is_numeric($storeId) || !key_exists($storeId, $this->storeRepository->getList())) {
$store = $this->storeRepository->getById($storeId);
} else {
$store = $this->storeRepository->get($storeId);
}
Or have I missed something out here?
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.
@dmanners $storeId
may be passed from outside as a method parameter. And this is actually the issue, as there are several places where ___store
query parameter just fetched from a query object and passed to store manager. Store resolver already implements a logic for correct handling of the invalid store code or id.
I'm worrying about this implementation as at this point we do not know exactly that $storeId
value comes from ___store
query parameter so any code issue will be silently handled without any notification and may lead to unpredictable result and hard to detect bugs.
I think we should find a solution in which only value of ___store
query parameter will be affected.
@lewisvoncken have you had any chance to look into this feedback and the tests? |
Hi
I will try to take a look at it tomorrow
On Fri, 10 Nov 2017 at 17:12, David Manners ***@***.***> wrote:
@lewisvoncken <https://github.com/lewisvoncken> have you had any chance
to look into this feedback and the tests?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11915 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFwrF_g-z9p2P1gxr2ABTDuNBvtaU7Hcks5s1HYEgaJpZM4QNhVm>
.
--
*Met vriendelijke groet / Best regards,*
Lewis Voncken
Developer
Arthur van Schendelstraat 650
030 - 8200 238
www.experius.nl
Volg ons! <https://www.facebook.com/Experius1>
<https://www.linkedin.com/company-beta/1008104>
<https://twitter.com/experiusnl>
|
|
||
return $store; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getCurrentStoreId() |
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.
As @dmanners mentioned there are no reasons to make this method public. For patch releases (2.1-develop and 2.2-develop) we should avoid introduction of new public methods to existing class even if they look as a good addition to a class public interface.
} elseif (key_exists($storeId, $this->storeRepository->getList())) { | ||
$store = $this->storeRepository->get($storeId); | ||
} else { | ||
$store = $this->storeRepository->getById($this->getCurrentStoreId()); |
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.
@dmanners $storeId
may be passed from outside as a method parameter. And this is actually the issue, as there are several places where ___store
query parameter just fetched from a query object and passed to store manager. Store resolver already implements a logic for correct handling of the invalid store code or id.
I'm worrying about this implementation as at this point we do not know exactly that $storeId
value comes from ___store
query parameter so any code issue will be silently handled without any notification and may lead to unpredictable result and hard to detect bugs.
I think we should find a solution in which only value of ___store
query parameter will be affected.
@dmanners working on it #magetestfest |
HI @lewisvoncken do you need any help with this PR? |
Hi @lewisvoncken I am going to close this PR due to inactivity. If you feel like getting back into this code feel free to re-raise this PR at a later date. |
Hi @lewisvoncken, can you please provide some update on this PR, as you reopened it after a year of inactivity. |
Closing due to inactivity. Feel free to contact me if you'd like to continue work on this pull request. Thanks for the collaboration! |
same as magento-partners/magento2ce#60
Description
When you try to switch to a non-existing or empty store code you the request will result in an Exception.
Fixed Issues (if relevant)
Manual testing scenarios