-
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
Correct the error message when creating wrong object for block #2037
Conversation
👍 |
@@ -260,7 +260,7 @@ protected function getBlockInstance($block, array $arguments = []) | |||
} | |||
if (!$block instanceof \Magento\Framework\View\Element\AbstractBlock) { | |||
throw new \Magento\Framework\Exception\LocalizedException( | |||
new \Magento\Framework\Phrase('Invalid block type: %1', [$block]) | |||
new \Magento\Framework\Phrase('Invalid block type: %1', [is_string($block) ? $block : get_class($block)]) |
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 code assumes that only string or object may be provided.
Please use more secure version:
is_object($block) ? get_class($block) : $block
Hi @hiephm could you please make those changes mentioned by @vkublytskyi ? |
… an AbstractBlock
Hiep Ho Minh seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. |
2867ee8
to
47ad2c7
Compare
@MomotenkoNatalia OK, I have updated the code. |
Internal ticket: MAGETWO-58370 |
@vkorotun @mmansoorebay is this PR going to be included in 2.1.3? |
In case the $block is neither string nor AbstractBlock (e.g in case use wrong class for block), the error message will become:
Should add the check for object and use get_class in that case.