Skip to content
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

Merged
merged 1 commit into from
Sep 28, 2016

Conversation

hiephm
Copy link

@hiephm hiephm commented Oct 6, 2015

In case the $block is neither string nor AbstractBlock (e.g in case use wrong class for block), the error message will become:

Invalid block type: %1

Should add the check for object and use get_class in that case.

@ihor-sviziev
Copy link
Contributor

👍

@@ -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)])

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

@MomotenkoNatalia
Copy link
Contributor

Hi @hiephm could you please make those changes mentioned by @vkublytskyi ?

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Aug 31, 2016

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

@hiephm hiephm force-pushed the bugs-error-message branch from 2867ee8 to 47ad2c7 Compare August 31, 2016 06:24
@hiephm
Copy link
Author

hiephm commented Aug 31, 2016

@MomotenkoNatalia OK, I have updated the code.

@vkorotun
Copy link
Contributor

Internal ticket: MAGETWO-58370

@vkorotun vkorotun added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development and removed Progress: needs update labels Sep 14, 2016
@mmansoor-magento mmansoor-magento merged commit 47ad2c7 into magento:develop Sep 28, 2016
@Ctucker9233
Copy link

@vkorotun @mmansoorebay is this PR going to be included in 2.1.3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Frontend bugfix Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Progress: accept
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants