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

Magento erroneously assums one category is parent of another based on category path #32464

Closed
1 of 5 tasks
dot319 opened this issue Mar 12, 2021 · 15 comments · Fixed by #35567
Closed
1 of 5 tasks

Magento erroneously assums one category is parent of another based on category path #32464

dot319 opened this issue Mar 12, 2021 · 15 comments · Fixed by #35567
Assignees
Labels
Area: Catalog Component: Catalog Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S1 Affects critical data or functionality and forces users to employ a workaround. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@dot319
Copy link

dot319 commented Mar 12, 2021

Preconditions (*)

  1. Magento 2.4-develop
  2. Admin side: Have a category tree where 2 categories exists side by wide, where 1 category id starts with the category id of the other. (Like id 14 and id 146.)
    For example:
  • Default Root Category (id:2)
    • Child Category Products (id:3)
      • Child-child category Example One (id:14)
      • Child-child category Example Two (id:146)
        Example Screenshot
        image

Steps to reproduce (*)

  1. Somewhere in the code base, call \Magento\Catalog\Model\CategoryManagement::move(14, 146) to try and move the category with id 14 into the category with id 146

Ex: We can call move method inside the new simple model controller class created as like below code:

protected $_pageFactory;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Catalog\Model\CategoryManagement $pageFactory)
{
$this->_pageFactory = $pageFactory;
return parent::__construct($context);
}

public function execute()
{
    echo "Hello World";//die;
    $this->_pageFactory->move(14, 146);
    echo "Manju11";
    die;
}

Expected result (*)

  1. The category with id 14 is moved into the category with id 146

Actual result (*)

  1. An error is thrown 'Operation do not allow to move a parent category to any of children category'

This happens because in the method \Magento\Catalog\Model\CategoryManagement::move there exists the assumption that if strpos($parentPath, $path) === 0, the category you are trying to move is a parent of the category you are trying to move it into. While actually in this case they are 'siblings', their paths are '1/2/14' and '1/2/146'.

Below is the complete report log generated:
{
"0": "Operation do not allow to move a parent category to any of children category",
"1": "#1 Mks\Helloworld\Controller\Index\Index->execute() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:58]\n#2 Mks\Helloworld\Controller\Index\Index\Interceptor->___callParent() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:138]\n#3 Mks\Helloworld\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:153]\n#4 Mks\Helloworld\Controller\Index\Index\Interceptor->___callPlugins() called at [generated\code\Mks\Helloworld\Controller\Index\Index\Interceptor.php:23]\n#5 Mks\Helloworld\Controller\Index\Index\Interceptor->execute() called at [lib\internal\Magento\Framework\App\Action\Action.php:111]\n#6 Magento\Framework\App\Action\Action->dispatch() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:58]\n#7 Mks\Helloworld\Controller\Index\Index\Interceptor->___callParent() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:138]\n#8 Mks\Helloworld\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:153]\n#9 Mks\Helloworld\Controller\Index\Index\Interceptor->___callPlugins() called at [generated\code\Mks\Helloworld\Controller\Index\Index\Interceptor.php:32]\n#10 Mks\Helloworld\Controller\Index\Index\Interceptor->dispatch() called at [lib\internal\Magento\Framework\App\FrontController.php:245]\n#11 Magento\Framework\App\FrontController->getActionResponse() called at [lib\internal\Magento\Framework\App\FrontController.php:212]\n#12 Magento\Framework\App\FrontController->processRequest() called at [lib\internal\Magento\Framework\App\FrontController.php:147]\n#13 Magento\Framework\App\FrontController->dispatch() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:58]\n#14 Magento\Framework\App\FrontController\Interceptor->___callParent() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:138]\n#15 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [app\code\Magento\Store\App\FrontController\Plugin\RequestPreprocessor.php:99]\n#16 Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:135]\n#17 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [app\code\Magento\PageCache\Model\App\FrontController\BuiltinPlugin.php:75]\n#18 Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:135]\n#19 Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() called at [lib\internal\Magento\Framework\Interception\Interceptor.php:153]\n#20 Magento\Framework\App\FrontController\Interceptor->___callPlugins() called at [generated\code\Magento\Framework\App\FrontController\Interceptor.php:23]\n#21 Magento\Framework\App\FrontController\Interceptor->dispatch() called at [lib\internal\Magento\Framework\App\Http.php:116]\n#22 Magento\Framework\App\Http->launch() called at [generated\code\Magento\Framework\App\Http\Interceptor.php:23]\n#23 Magento\Framework\App\Http\Interceptor->launch() called at [lib\internal\Magento\Framework\App\Bootstrap.php:264]\n#24 Magento\Framework\App\Bootstrap->run() called at [pub\index.php:29]\n",
"url": "/Mks/Index/Index",
"script_name": "/index.php",
"report_id": "876d49429e34c918d1163ad0b48fb02baab92e59889dec335691fc4e0b137805"
}


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Mar 12, 2021

Hi @dot319. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

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

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@dot319
Copy link
Author

dot319 commented Mar 12, 2021

I confirmed this issue on my local vanilla Magento environment.

@engcom-Oscar engcom-Oscar added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Mar 12, 2021
@stale
Copy link

stale bot commented May 27, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

@stale stale bot added the stale issue label May 27, 2021
@stale stale bot closed this as completed Jun 10, 2021
@m2-community-project m2-community-project bot removed this from Ready for Confirmation in Issue Confirmation and Triage Board Jun 10, 2021
@hostep
Copy link
Contributor

hostep commented Jun 11, 2021

This shouldn't have been closed, it sounds valid at first sight. @Den4ik or @ihor-sviziev, can we get somebody to verify this first before it gets closed without any attention? Thanks!

@ihor-sviziev
Copy link
Contributor

@gabrieldagama, feels like it should be prioritized as P1 or P2

@engcom-Alfa engcom-Alfa self-assigned this Jun 14, 2021
@m2-assistant
Copy link

m2-assistant bot commented Jun 14, 2021

Hi @engcom-Alfa. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Alfa
Copy link
Contributor

@magento give me 2.4-develop instance

@magento-deployment-service
Copy link

Hi @engcom-Alfa. Thank you for your request. I'm working on Magento instance for you.

@engcom-Alfa engcom-Alfa added Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response labels Jun 17, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Jun 17, 2021
@m2-community-project m2-community-project bot removed the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Jun 17, 2021
mozok added a commit to mozok/magento2 that referenced this issue May 31, 2022
…nother based on category path

- Update Unit test to reproduce issue
- Fix check for parent category path
@m2-community-project m2-community-project bot moved this from Dev In Progress to Pull Request In Progress in High Priority Backlog May 31, 2022
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Ready for Development in High Priority Backlog Jun 1, 2022
mozok added a commit to mozok/magento2 that referenced this issue Jun 1, 2022
…nother based on category path

- Update Unit test to reproduce issue
- Fix check for parent category path
@m2-community-project m2-community-project bot moved this from Ready for Development to Pull Request In Progress in High Priority Backlog Jun 1, 2022
mozok added a commit to mozok/magento2 that referenced this issue Jun 1, 2022
…nother based on category path

- Update Unit test to reproduce issue
- Fix check for parent category path
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Ready for Development in High Priority Backlog Jun 1, 2022
@m2-community-project m2-community-project bot moved this from Ready for Development to Pull Request In Progress in High Priority Backlog Jun 1, 2022
@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Done in High Priority Backlog Jul 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Catalog Component: Catalog Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S1 Affects critical data or functionality and forces users to employ a workaround. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
10 participants