magento2: [2.1.0] HTML minification problem with php tag with a comment and no space at the end
Steps to reproduce
- Install Magento 2.1.0 using composer
- Create a theme and a template file which contains this:
<?php //if ($showDescription):?>
<div class="product description product-item-description">
<?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?>
</div>
<?php //endif; ?>
- Turn on html minification in the backend
Expected result
- Page is rendered properly without errors
Actual result
- Error message appears:
Parse error: syntax error, unexpected '<'
.
The minified php/html file was turned into:
<?php <div class="product description product-item-description"><?php /* @escapeNotVerified */ echo $_helper->productAttribute($_product, $_product->getShortDescription(), 'short_description') ?></div><?php ?>
Temporary solution
Add a space at the end and it works again, like this:
<?php //if ($showDescription): ?>
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 4
- Comments: 26 (13 by maintainers)
Commits related to this issue
- Fix HTML minification problem #5316 — committed to lisovyievhenii/magento2 by lisovyievhenii 6 years ago
- Adjust html minifier test to cover possible cases of issue #5316 — committed to lisovyievhenii/magento2 by lisovyievhenii 6 years ago
Hi @hostep. Thank you for your report. The issue has been fixed in magento/magento2#16332 by @lisovyievhenii in 2.3-develop branch Related commit(s):
The fix will be available with the upcoming 2.3.0 release.
I am working on this at #dmcdindia
@pantaoran: it’s only for php tags with php code which is commented out in phtml files. I haven’t searched the Magento core code if there are offending files like that, in our case it was a file in our custom theme. I don’t think your regex searches for commented out code?
Although I agree that all phtml files which contain
{something}?>
should be replaced with{something} ?>
(including a space) to have everything consistent.I’m using 2.1.6 and I’m having the same issues with html minimication