-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Fix app/code/Magento/Backend/Block/Media/Uploader.php getConfigJson() method #11665
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
Fix app/code/Magento/Backend/Block/Media/Uploader.php getConfigJson() method #11665
Conversation
@@ -28,15 +30,24 @@ class Uploader extends \Magento\Backend\Block\Widget | |||
protected $_fileSizeService; | |||
|
|||
/** | |||
* @var \Magento\Framework\Json\EncoderInterface | |||
*/ | |||
protected $_jsonEncoder; |
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 remove _
and make it private
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.
It's the way it's done at \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links::getConfigJson, but I'll change it.
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.
Done
724f747
to
86f3c39
Compare
*/ | ||
public function __construct( | ||
\Magento\Backend\Block\Template\Context $context, | ||
\Magento\Framework\File\Size $fileSize, | ||
array $data = [] | ||
array $data = [], | ||
\Magento\Framework\Json\EncoderInterface $jsonEncoder = null |
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 interface is deprecated, please check https://github.com/magento/magento2/pull/10342/files#r129685891 for an up-to-date way to inject JSON encoder.
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.
Good to know it and the reason why 👍
) { | ||
$this->jsonEncoder = $jsonEncoder ?: | ||
ObjectManager::getInstance()->get(\Magento\Framework\Json\EncoderInterface::class); |
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.
Try using imports (Alt+Enter in PhpStorm) at least for such cases, probably it could fit in one line.
…using undefined class property _coreData
86f3c39
to
2d6458a
Compare
@orlangur Done. |
…getConfigJson() method #11665
…getConfigJson() method #11665
This method is using an undefined class property _coreData, that method cannot work, only crash if called, since it will try to call jsonEncode() method from a null property (even if defined dynamically).
Description
Adapted to use \Magento\Framework\Json\EncoderInterface instead of (probably) legacy code, the way it's done at \Magento\Downloadable\Block\Adminhtml\Catalog\Product\Edit\Tab\Downloadable\Links::getConfigJson.
Fixed Issues (if relevant)
It may be related with some open issue, but after searching, I didn't find one that may be caused by this method.
Contribution checklist