-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix: Render script in secure tag #797
- Loading branch information
1 parent
49565b2
commit e3c7f9c
Showing
4 changed files
with
56 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e3c7f9c
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.
@michielgerritsen, your module claims to be compatible with Magento 2.3.3 and higher. But the
Magento\Framework\View\Helper\SecureHtmlRenderer
class was only introduced in Magento 2.4.0, so either you'll need to check if it exists before trying to use it, or drop support for Magento 2.3.x, otherwise this code will crash on Magento 2.3.x shops.Also, there is a bug in Magento < 2.4.0 when using heredoc syntax (like your
<<<SCRIPT
) that breaks when html minification is enabled. That was also fixed in Magento 2.4.0 and higher.See discussions in yireo/Yireo_GoogleTagManager2#231 & algolia/algoliasearch-magento-2#1541 for where similar issues were discussed in other open source modules.
e3c7f9c
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.
Strange that your automated tests don't pick this up...
Running phpstan locally with level 1 on a Magento 2.3.7-p4 shop gives these problems:
If we increase phpstan to level 2, the problems becomes clearer:
e3c7f9c
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.
@hostep Awesome feedback, thanks! The code has been updated.
It looks like the PHPStan check isn't working as expected. I have noted this and will look into it later.
e3c7f9c
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.
Indeed; Thank you so much for taking the time and effort to do this, @hostep. It’s truly helpful!