Skip to content

Chore: Catalog Widget - Replace Block Escaping with Escaper #37082

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

Closed
wants to merge 1 commit into from

Conversation

pykettk
Copy link
Member

@pykettk pykettk commented Mar 9, 2023

Description (*)

Refactors the Magento_CatalogWidget module to replace $block escaping functions with $escaper escaping functions.

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)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Chore: Catalog Widget - Replace Block Escaping with Escaper #37107: Chore: Catalog Widget - Replace Block Escaping with Escaper

@m2-github-services m2-github-services added Partner: Fisheye partners-contribution Pull Request is created by Magento Partner labels Mar 9, 2023
@m2-assistant
Copy link

m2-assistant bot commented Mar 9, 2023

Hi @pykettk. Thank you for your contribution!
Here are some useful tips on 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 give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@pykettk
Copy link
Member Author

pykettk commented Mar 9, 2023

@magento create issue

Copy link
Contributor

@andrewbess andrewbess left a comment

Choose a reason for hiding this comment

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

Hello @pykettk
Thank you for your contribution here.

@m2-community-project m2-community-project bot added Progress: ready for testing Priority: P2 A defect with this priority could have functionality issues which are not to expectations. and removed Progress: pending review labels Mar 9, 2023
@engcom-Lima engcom-Lima self-assigned this Mar 15, 2023
@engcom-Lima
Copy link
Contributor

✔️ QA Passed

Preconditions:

  • Install fresh Magento 2.4-develop and PHP 8.1

Manual testing scenario:

  • In code base verify $block replaces with $escaper in the app/code/Magento/CatalogWidget/view/adminhtml/templates/product/widget/conditions.phtml

and app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml

Before: ✖️

Screenshot 2023-03-15 at 5 18 30 PM

After: ✔️
Screenshot 2023-03-15 at 4 00 35 PM

Additionally tested:

  1. Create, Edit and deleted the widget.
  2. Verified the created widget functionality in the frontend.
  3. Verified the admin grid of widget.

No additional manual testing is required as a part of regression cycle as this PR is related to the refactoring of the code base.

As builds are failed. Hence, moving this PR to Extended testing

@engcom-Lima
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Delta
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE, Static Tests, Unit Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

2 similar comments
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Delta
Copy link
Contributor

@magento run Static Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

1 similar comment
@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Charlie
Copy link
Contributor

Hi @pykettk,

Thank you for the contribution!

As your branch is forked from https://github.com/mage-os/mageos-magento2.git, we can not able to work on it. Can you please have a look at them else we have to create a new PR from branch forked from https://github.com/magento/magento2.git and close this one.

Thank you!

@pykettk
Copy link
Member Author

pykettk commented Mar 20, 2023

@engcom-Charlie What changes would you like me to make?

@engcom-Charlie
Copy link
Contributor

@magento run Static Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Lima
Copy link
Contributor

engcom-Lima commented Mar 21, 2023

Hi @pykettk ,

@engcom-Charlie What changes would you like me to make?

In order to move ahead to merge in progress all builds should be green. As build is failing our team have to work on it but as your PR is forked from mage-os we can't proceed further on it.
Please check this comment and please act accordingly.

Thanks

@pykettk
Copy link
Member Author

pykettk commented Mar 21, 2023

@engcom-Lima Your response doesn't answer the question. Please act accordingly and please have a look at them are not clear instructions. I'm more than happy to help unstick this problem but it is not clear to me what you need me to do. Please do not close this PR whilst I am showing a willingness to be helpful 🙂

@pykettk
Copy link
Member Author

pykettk commented Mar 21, 2023

@magento run Static Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@engcom-Charlie
Copy link
Contributor

Hi @pykettk,

In general, when PR is showing build failures, we need to work on it. It will get move to Merge only when the build is successful. For this PR, we engcom team, not able to work on your PR as your branch is forked from https://github.com/mage-os/mageos-magento2.git

As mentioned in comment, either you please have a look at the build failures or please raise a new PR from branch forked from https://github.com/magento/magento2.git and close this one.

Thank you!

@pykettk
Copy link
Member Author

pykettk commented Mar 23, 2023

@engcom-Charlie I'd really like to look at the failing checks however the report is unavailable - see below.
image

Please advise.

@pykettk
Copy link
Member Author

pykettk commented Mar 23, 2023

@magento run Static Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

Copy link
Member

@fredden fredden left a comment

Choose a reason for hiding this comment

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

I've manually run vendor/bin/phpcs --standard=Magento2Framework -sp --basepath=$PWD --colors app/code/Magento/CatalogWidget/view/frontend/templates/product/widget/content/grid.phtml app/code/Magento/CatalogWidget/view/adminhtml/templates/product/widget/conditions.phtml and this is what it is complaining about:

FILE: app/code/Magento/CatalogWidget/view/adminhtml/templates/product/widget/conditions.phtml
--------------------------------------------------------------------------------------------------------
FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES
--------------------------------------------------------------------------------------------------------
 17 | WARNING | Line exceeds 120 characters; contains 122 characters
    |         | (Generic.Files.LineLength.TooLong)
 40 | WARNING | Line exceeds 120 characters; contains 123 characters
    |         | (Generic.Files.LineLength.TooLong)
--------------------------------------------------------------------------------------------------------

I suspect this is why the automated Static Tests are failing. There were no complains from vendor/bin/phpmd which is also run as part of the automated Static Tests.

$fieldId = $element->getHtmlContainerId() ? ' id="' . $block->escapeHtmlAttr($element->getHtmlContainerId()) . '"' : '';
$fieldClass = 'field admin__field field-' . $block->escapeHtmlAttr($element->getId()) . ' '
. $block->escapeHtmlAttr($element->getCssClass());
$fieldId = $element->getHtmlContainerId() ? ' id="' . $escaper->escapeHtmlAttr($element->getHtmlContainerId()) . '"' : '';
Copy link
Member

Choose a reason for hiding this comment

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

phpcs says this line is too long (122 characters, limit is 120)

@@ -31,8 +37,8 @@ $fieldAttributes = $fieldId . ' class="' . $fieldClass . '" '
"Magento_Rule/rules",
"prototype"
], function(VarienRulesForm){
window.{$block->escapeJs($block->getHtmlId())} = new VarienRulesForm('{$block->escapeJs($block->getHtmlId())}',
'{$block->escapeUrl($block->getNewChildUrl())}');
window.{$escaper->escapeJs($block->getHtmlId())} = new VarienRulesForm('{$escaper->escapeJs($block->getHtmlId())}',
Copy link
Member

Choose a reason for hiding this comment

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

phpcs says this line is too long (123 characters, limit is 120)

@fredden
Copy link
Member

fredden commented Mar 24, 2023

I've manually run vendor/bin/phpcs --standard=Magento2Framework ...

Note that I have magento/magento-coding-standard#417 applied locally, so when I say Magento2Framework, I mean Magento2 and Magento2Framework.

@pykettk
Copy link
Member Author

pykettk commented Mar 24, 2023

Thanks for the input, @fredden , this is very helpful! I'll look to get these resolved now 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Partner: Fisheye partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Chore: Catalog Widget - Replace Block Escaping with Escaper
7 participants