Skip to content

Issue 5316#16332

Merged
magento-engcom-team merged 3 commits intomagento:2.3-developfrom
lisovyievhenii:issue-5316
Jun 26, 2018
Merged

Issue 5316#16332
magento-engcom-team merged 3 commits intomagento:2.3-developfrom
lisovyievhenii:issue-5316

Conversation

@lisovyievhenii
Copy link
Copy Markdown
Contributor

Description

Fix HTML minification problem, when there is a php a comment and no space at the php end tag

Fixed Issues (if relevant)

  1. [2.1.0] HTML minification problem with php tag with a comment and no space at the end #5316: [2.1.0] HTML minification problem with php tag with a comment and no space at the end

Manual testing scenarios

  1. 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; ?>
  1. Enable HTML minification in the backend
  2. Re-deploy static content and view_preprocessed in order to generate minified templates
  3. Check the front page, where template is used.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-cicd2
Copy link
Copy Markdown
Contributor

magento-cicd2 commented Jun 22, 2018

CLA assistant check
All committers have signed the CLA.

@magento-engcom-team
Copy link
Copy Markdown
Contributor

Hi @lisovyievhenii. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento-engcom-team give me test instance - deploy test instance based on PR changes
  • @magento-engcom-team give me {$VERSION} instance - deploy vanilla Magento instance

For more details, please, review the Magento Contributor Assistant documentation

@phoenix128 phoenix128 self-assigned this Jun 22, 2018
Copy link
Copy Markdown
Contributor

@phoenix128 phoenix128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @lisovyievhenii ,
thank you for your contribution, would you please check my reviews? Thank you.

'#(?<!:|\'|")//[^\n\r]*(\s\?\>)#',
'$1',
'#(?<!:|\'|")//[^\n\r]*(\?\>)#',
' $1',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you did not simpy change the regular expression in #(?<!:|'|")//[^\n\r]*(\s*\?\>)#, instead of adding the prefixing space in the replacement?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case if the code will be like this one:

<?php//else:?>

if the replacement string will be just '$1', we will get the result:

<?php?>

So it will cause calling of undefined conftant php and to prevent it I added the prefixing space in the replacement.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, right point.

@phoenix128
Copy link
Copy Markdown
Contributor

@lisovyievhenii ,
I think we should also change \Magento\Framework\View\Test\Unit\Template\Html\MinifierTest::testMinify to cover both cases. Do you think you can do it?
Thank you.

@lisovyievhenii
Copy link
Copy Markdown
Contributor Author

Ok, I will adjust \Magento\Framework\View\Test\Unit\Template\Html\MinifierTest::testMinify to cover possible cases.

Copy link
Copy Markdown
Contributor

@phoenix128 phoenix128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @lisovyievhenii for your work and for your time. We appreciate it.

@magento-engcom-team
Copy link
Copy Markdown
Contributor

Hi @phoenix128, thank you for the review.
ENGCOM-2112 has been created to process this Pull Request

@magento-engcom-team
Copy link
Copy Markdown
Contributor

Hi @lisovyievhenii. Thank you for your contribution.
Changes from your Pull Request will be available with the upcoming 2.3.0 release.

This was referenced Jul 18, 2018
@lisovyievhenii lisovyievhenii added the Partner: ISM eCompany Pull Request is created by partner ISM eCompany label Aug 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants