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

Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails #23071

Closed
adarshkhatri opened this issue May 31, 2019 · 12 comments
Assignees
Labels
Component: Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed 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 Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@adarshkhatri
Copy link
Contributor

adarshkhatri commented May 31, 2019

Preconditions (*)

  1. Magento 2.3.0
  2. Magneto 1.x

Steps to reproduce (*)

  1. Use this url http:://www.domain.com/catalog/product_compare/index/items/ab

Expected result (*)

  1. should display 404 or another error message or it shouldn't even reach to the sql insertion point. I know this link is not anywhere in the site, however, intruders are trying this link. There might be some vulnerability too (I haven't come across yet).

Actual result (*)

2 exception(s):
Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (database_name.catalog_compare_item, CONSTRAINT CATALOG_COMPARE_ITEM_PRODUCT_ID_SEQUENCE_PRODUCT_SEQUENCE_VALUE FOREIGN KEY (product_id) REFERENCES sequence_product (sequence_value)), query was: INSERT INTO catalog_compare_item (customer_id, store_id) VALUES (?, ?)
Exception #1 (PDOException): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (database_name.catalog_compare_item, CONSTRAINT CATALOG_COMPARE_ITEM_PRODUCT_ID_SEQUENCE_PRODUCT_SEQUENCE_VALUE FOREIGN KEY (product_id) REFERENCES sequence_product (sequence_value))

Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (database_name.catalog_compare_item, CONSTRAINT CATALOG_COMPARE_ITEM_PRODUCT_ID_SEQUENCE_PRODUCT_SEQUENCE_VALUE FOREIGN KEY (product_id) REFERENCES sequence_product (sequence_value)), query was: INSERT INTO catalog_compare_item (customer_id, store_id) VALUES (?, ?)
#0 /vendor/magento/framework/DB/Statement/Pdo/Mysql.php(93): Zend_Db_Statement_Pdo->_execute(Array)
#1 /vendor/magento/zendframework1/library/Zend/Db/Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array)
#2 /vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO ca...', Array) #4 /vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(541): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO ca...', Array)
#5 /vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(615): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('INSERT INTO ca...', Array) #6 /vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(576): Magento\Framework\DB\Adapter\Pdo\Mysql->query('INSERT INTO ca...', Array)
#7 /vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(774): Zend_Db_Adapter_Abstract->insert('catalog_compare...', Array)
#8 /vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(416): Magento\Framework\Model\ResourceModel\Db\AbstractDb->saveNewObject(Object(Magento\Catalog\Model\Product\Compare\Item))
#9 /vendor/magento/framework/Model/AbstractModel.php(648): Magento\Framework\Model\ResourceModel\Db\AbstractDb->save(Object(Magento\Catalog\Model\Product\Compare\Item))
#10 /vendor/magento/module-catalog/Model/Product/Compare/ListCompare.php(95): Magento\Framework\Model\AbstractModel->save()
#11 /vendor/magento/module-catalog/Model/Product/Compare/ListCompare.php(111): Magento\Catalog\Model\Product\Compare\ListCompare->addProduct('ab')
#12 /vendor/magento/module-catalog/Controller/Product/Compare/Index.php(90): Magento\Catalog\Model\Product\Compare\ListCompare->addProducts(Array)
#13 /generated/code/Magento/Catalog/Controller/Product/Compare/Index/Interceptor.php(24): Magento\Catalog\Controller\Product\Compare\Index->execute()
#14 /vendor/magento/framework/App/Action/Action.php(108): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->execute()
#15 /vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#16 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->___callParent('dispatch', Array)
#17 /vendor/magento/module-customer-segment/Model/App/Action/ContextPlugin.php(81): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#18 /vendor/magento/framework/Interception/Interceptor.php(135): Magento\CustomerSegment\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Catalog\Controller\Product\Compare\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#19 /vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#20 /generated/code/Magento/Catalog/Controller/Product/Compare/Index/Interceptor.php(52): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#21 /vendor/magento/framework/App/FrontController.php(159): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#22 /vendor/magento/framework/App/FrontController.php(99): Magento\Framework\App\FrontController->processRequest(Object(Magento\Framework\App\Request\Http), Object(Magento\Catalog\Controller\Product\Compare\Index\Interceptor))
#23 /vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#24 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#25 /vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#26 /vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#27 /vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#28 /vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#29 /vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#30 /generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, NULL)
#31 /vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#32 /generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()
#33 /vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http\Interceptor->launch()
#34 /index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#35 {main}

Exception #1 (PDOException): SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (database_name.catalog_compare_item, CONSTRAINT CATALOG_COMPARE_ITEM_PRODUCT_ID_SEQUENCE_PRODUCT_SEQUENCE_VALUE FOREIGN KEY (product_id) REFERENCES sequence_product (sequence_value))
#0 /vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 /vendor/magento/framework/DB/Statement/Pdo/Mysql.php(93): Zend_Db_Statement_Pdo->_execute(Array)
#2 /vendor/magento/zendframework1/library/Zend/Db/Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array)
#3 /vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#4 /vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO ca...', Array) #5 /vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(541): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO ca...', Array)
#6 /vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(615): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('INSERT INTO ca...', Array) #7 /vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(576): Magento\Framework\DB\Adapter\Pdo\Mysql->query('INSERT INTO ca...', Array)
#8 /vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(774): Zend_Db_Adapter_Abstract->insert('catalog_compare...', Array)
#9 /vendor/magento/framework/Model/ResourceModel/Db/AbstractDb.php(416): Magento\Framework\Model\ResourceModel\Db\AbstractDb->saveNewObject(Object(Magento\Catalog\Model\Product\Compare\Item))
#10 /vendor/magento/framework/Model/AbstractModel.php(648): Magento\Framework\Model\ResourceModel\Db\AbstractDb->save(Object(Magento\Catalog\Model\Product\Compare\Item))
#11 /vendor/magento/module-catalog/Model/Product/Compare/ListCompare.php(95): Magento\Framework\Model\AbstractModel->save()
#12 /vendor/magento/module-catalog/Model/Product/Compare/ListCompare.php(111): Magento\Catalog\Model\Product\Compare\ListCompare->addProduct('ab')
#13 /vendor/magento/module-catalog/Controller/Product/Compare/Index.php(90): Magento\Catalog\Model\Product\Compare\ListCompare->addProducts(Array)
#14 /generated/code/Magento/Catalog/Controller/Product/Compare/Index/Interceptor.php(24): Magento\Catalog\Controller\Product\Compare\Index->execute()
#15 /vendor/magento/framework/App/Action/Action.php(108): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->execute()
#16 /vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#17 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->___callParent('dispatch', Array)
#18 /vendor/magento/module-customer-segment/Model/App/Action/ContextPlugin.php(81): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#19 /vendor/magento/framework/Interception/Interceptor.php(135): Magento\CustomerSegment\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Catalog\Controller\Product\Compare\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#20 /vendor/magento/framework/Interception/Interceptor.php(153): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#21 /generated/code/Magento/Catalog/Controller/Product/Compare/Index/Interceptor.php(52): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#22 /vendor/magento/framework/App/FrontController.php(159): Magento\Catalog\Controller\Product\Compare\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#23 /vendor/magento/framework/App/FrontController.php(99): Magento\Framework\App\FrontController->processRequest(Object(Magento\Framework\App\Request\Http), Object(Magento\Catalog\Controller\Product\Compare\Index\Interceptor))
#24 /vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#25 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#26 /vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#27 /vendor/magento/framework/Interception/Interceptor.php(135): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#28 /vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#29 /vendor/magento/framework/Interception/Interceptor.php(135): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#30 /vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))
#31 /generated/code/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, NULL)
#32 /vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#33 /generated/code/Magento/Framework/App/Http/Interceptor.php(24): Magento\Framework\App\Http->launch()
#34 /vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http\Interceptor->launch()
#35 /index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#36 {main}

@m2-assistant
Copy link

m2-assistant bot commented May 31, 2019

Hi @adarshkhatri. 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.3-develop instance - upcoming 2.3.x release

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

@adarshkhatri do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label May 31, 2019
@adarshkhatri
Copy link
Contributor Author

@magento give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri, here is your Magento instance.
Admin access: https://i-23071-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@m2-assistant
Copy link

m2-assistant bot commented May 31, 2019

Hi @AlexWorking. 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.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

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

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

@dmytro-ch dmytro-ch self-assigned this May 31, 2019
@m2-assistant
Copy link

m2-assistant bot commented May 31, 2019

Hi @dmytro-ch. 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.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

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

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

@dmytro-ch dmytro-ch added Component: Catalog Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels May 31, 2019
@magento-engcom-team
Copy link
Contributor

✅ Confirmed by @dmytro-ch
Thank you for verifying the issue. Based on the provided information internal tickets MC-17147 were created

Issue Available: @dmytro-ch, 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 May 31, 2019
@AlexWorking AlexWorking removed their assignment May 31, 2019
@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri, @adarshkhatri.

Thank you for your report and collaboration!

The issue was fixed by Magento team. The fix was delivered into magento/magento2:2.2.10-develop branch(es).
Related commit(s):

The fix will be available with the upcoming 2.2.10 release.

@magento-engcom-team magento-engcom-team added Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line labels Aug 2, 2019
@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri, @adarshkhatri.

Thank you for your report and collaboration!

The issue was fixed by Magento team. The fix was delivered into magento/magento2:2.3.3-develop branch(es).
Related commit(s):

The fix will be available with the upcoming 2.3.3 release.

@adarshkhatri
Copy link
Contributor Author

@magento give me 2.3-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri. Thank you for your request. I'm working on Magento 2.3-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @adarshkhatri, here is your Magento instance.
Admin access: https://i-23071-2-3-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed 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 Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests

4 participants