Fix Product Links always being processed in afterSave#40746
Fix Product Links always being processed in afterSave#40746OddScenario wants to merge 1 commit intomagento:2.4-developfrom
Conversation
|
Hi @OddScenario. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
|
@magento run all tests |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
3 similar comments
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
|
The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com. |
Description (*)
Magento\Catalog\Model\Product::afterSave()unconditionally calledgetLinkInstance()->saveProductRelations($this)on every save, re-processing product links even when the caller explicitly indicated that links should be left untouched.Magento\Catalog\Model\ProductRepositoryalready exposes anignore_links_flagto opt out of link pre-processing, butafterSave()never checked that flag — so the unchanged product_links were still re-processed and written to the database on every save.This becomes visible under concurrent saves against the same product (e.g. updating multiple storeviews in parallel). The post-processing races with itself and fails with:
even when the PUT body contains no
product_linksat all.This PR makes
afterSave()respectignore_links_flag, and updatesProductRepository::processLinks()to set theignore_links_flagwhen the links arenull.Manual testing scenarios (*)
Preconditions: a Magento instance with ≥2 storeviews and at least 1 product that has related / upsell / crosssell links configured (e.g. 24-MB01 from sample data).
Contribution checklist (*)