orocommerce icon indicating copy to clipboard operation
orocommerce copied to clipboard

PriceListTreeHandler TypeErrors fix

Open artoasmith opened this issue 4 years ago • 3 comments

PriceListTreeHandler TypeErrors fix in case when Oro\Bundle\WebsiteBundle\Manager\WebsiteManager::getCurrentWebsite returns null value.

Related to https://github.com/oroinc/orocommerce/issues/118

artoasmith avatar Sep 25 '20 18:09 artoasmith

Thank you for your pull request.

It looks like this may be your first contribution to an Oro, Inc. open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://oroinc.com/b2b-ecommerce/contributor-license-agreement/

If you've already signed the CLA, it's possible we don't have your GitHub username or you're using a different email address. GitHub uses the email address you set in your local Git configuration to associate commits with your GitHub account. Please sign the CLA again using the correct GitHub username and email address or see this help article on setting the email on your git commits.

Once you've signed the CLA, please allow for some time for the submission to be processed.

orocla avatar Sep 25 '20 19:09 orocla

Hi @artoasmith,

Thank you for the proposed fix.

I do not see though why you want this method to silently ignore the problem. Normally, if this method is called somewhere in the context of processing a storefront web request, the website manager service will return some non-null website. And if you want to use this method in the back-office (or message processor, or console command, etc.), you would pass a website as a parameter. Logically then the fix would be to add a guard and trigger an exception, and describe this in the method's phpdoc, e.g.

if (null ===$website) {
    throw new \LogicException(\sprintf('When %s is called not in a storefront context, a website must be passed as a parameter, __METHOD__));
}

Please provide the STR or a stacktrace of how you got this method called without a website parameter and not on a storefront.

Thank you.

mbessolov avatar Sep 26 '20 00:09 mbessolov

I found this exception after initializing storefront Datagrid on the back-office. As a result, I got a TypeError exception instead of more propper.

artoasmith avatar Sep 29 '20 07:09 artoasmith