Skip to content
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

[Issue] Prevent side effect on category objects store_id and url_key on save #29585

Closed
4 tasks
m2-assistant bot opened this issue Aug 17, 2020 · 2 comments · Fixed by #28164
Closed
4 tasks

[Issue] Prevent side effect on category objects store_id and url_key on save #29585

m2-assistant bot opened this issue Aug 17, 2020 · 2 comments · Fixed by #28164
Labels
Component: CatalogUrlRewrite Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.0 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.

Comments

@m2-assistant
Copy link

m2-assistant bot commented Aug 17, 2020

This issue is automatically created based on existing pull request: #28164: Prevent side effect on category objects store_id and url_key on save


Preconditions (*)

Magento 2.4-develop

Category URL rewrites are saved by an "after save" observer for categories. But if saved for global scope, the URL rewrite generator itself modifies the passed category object for each assigned store to generate URL rewrites for all stores. Afterwards, url_key, url_path and store_id have the values of the last processed store id. This has side effects on later observers or other code that works on the category object after saving it.

Since the default store (0) is always the first item of $category->getStoreIds() I chose to clone the category object only for the other stores, so that url_key and url_path for the global scope are still set to the original object.

Related Pull Requests

Fixed Issues (if relevant)

  1. magento/magento2#<issue_number>: Issue title

Steps to reproduce (*)

Abbreviated test case

$category->setStoreId(0);
$category->setUrlKey('url-key-for-global-scope');
$categoryResource->save($category);

Expected result (*)

$category->getStoreId() should return 0

Actual result (*)

$category->getStoreId() returns value of the last processed store id.
image

Questions or comments

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 are green)
@m2-assistant m2-assistant bot added Component: CatalogUrlRewrite Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround. labels Aug 17, 2020
@ghost ghost assigned schmengler Aug 17, 2020
@ghost ghost added this to Ready for QA in Community Backlog Aug 17, 2020
@ghost ghost moved this from Ready for QA to PR In Progress in Community Backlog Aug 17, 2020
@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Aug 17, 2020
@ghost ghost moved this from PR In Progress to Ready for QA in Community Backlog Sep 22, 2020
@magento-engcom-team magento-engcom-team added Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed labels Sep 22, 2020
@engcom-Alfa engcom-Alfa added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Sep 22, 2020
@ghost ghost moved this from Ready for QA to Ready for Dev in Community Backlog Sep 22, 2020
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @engcom-Alfa
Thank you for verifying the issue. Based on the provided information internal tickets MC-37815 were created

Issue Available: @engcom-Alfa, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@magento-engcom-team magento-engcom-team added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Sep 22, 2020
@gabrieldagama gabrieldagama added the Fixed in 2.4.x The issue has been fixed in 2.4-develop branch label Sep 23, 2020
@gabrieldagama
Copy link
Contributor

Hi @m2-assistant[bot]. Thank you for your report.
The issue has been fixed in #28164 by @schmengler in 2.4-develop branch
Related commit(s):

The fix will be available with the upcoming 2.4.2 release.

@ghost ghost moved this from Ready for Dev to Done (last 30 days) in Community Backlog Sep 23, 2020
@magento-engcom-team magento-engcom-team added the Reported on 2.4.0 Indicates original Magento version for the Issue report. label Nov 13, 2020
@m2-community-project m2-community-project bot removed this from Done (last 30 days) in Community Backlog Nov 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: CatalogUrlRewrite Fixed in 2.4.x The issue has been fixed in 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.0 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S3 Affects non-critical data or functionality and does not force users to employ a workaround.
Projects
Development

Successfully merging a pull request may close this issue.

4 participants