-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Check return value for getProduct() in getPrice(). #7794
Conversation
If getProduct() returns a NULL value then this code will generate a PHP warning and potentially crash the page; let's not do that, and check our return values before we try to call methods on them.
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 consider saving results of getCustomOption() and getProduct() calls. Also please address static test feedback.
Save results of methods called and clean up code in response to feedback and tests.
return $product->getCustomOption('simple_product')->getProduct()->getPrice(); | ||
} else { | ||
return 0; | ||
if ( !empty( $product ) ) { |
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 check is not required
@pbaylies Thank you for contribution. Can you please fix following code styles issues:
|
@vrann I can't reproduce this; I don't see any extra spaces at the end of those lines on my committed file. |
these lines
should look like this:
|
Coding style updates.
@vrann Done, thanks! |
@pbaylies Thank you! |
@pbaylies merged! |
…value for getProduct() in getPrice(). magento#7794 - Merge Pull Request magento#7794 from pbaylies/magento2:patch-2 (cherry picked from commit 6752968)
If getProduct() returns a NULL value then this code will generate a PHP warning and potentially crash the page; let's not do that, and check our return values before we try to call methods on them.