当我尝试在Permission>下向用户添加REST角色时,会发生以下情况:用户。尝试创建所有用户并禁用缓存,但仍然会出现同样的问题。
任何解决方案都会有所帮助。
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`mag_db`.`api2_acl_user`, CONSTRAINT `FK_API2_ACL_USER_ADMIN_ID_ADMIN_USER_USER_ID` FOREIGN KEY (`admin_id`) REFERENCES `admin_user` (`user_id`) ON DELETE CASCADE ON UPDATE CASCADE), query was: INSERT INTO `api2_acl_user` (`admin_id`, `role_id`) VALUES (?, ?)
Trace:
#0 /home/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /home/public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /home/public_html/lib/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 /home/public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ap...', Array)
#4 /home/public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(504): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ap...', Array)
#5 /home/public_html/lib/Zend/Db/Adapter/Abstract.php(576): Varien_Db_Adapter_Pdo_Mysql->query('INSERT INTO `ap...', Array)
#6 /home/public_html/app/code/core/Mage/Api2/Model/Resource/Acl/Global/Role.php(74): Zend_Db_Adapter_Abstract->insert('api2_acl_user', Array)
#7 /home/public_html/app/code/core/Mage/Api2/Model/Observer.php(56): Mage_Api2_Model_Resource_Acl_Global_Role->saveAdminToRoleRelation('4', '4')
#8 /home/public_html/app/code/core/Mage/Core/Model/App.php(1358): Mage_Api2_Model_Observer->saveAdminToRoleRelation(Object(Varien_Event_Observer))
#9 /home/public_html/app/code/core/Mage/Core/Model/App.php(1337): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Api2_Model_Observer), 'saveAdminToRole...', Object(Varien_Event_Observer))
#10 /home/public_html/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('admin_user_save...', Array)
#11 /home/app/code/core/Mage/Core/Model/Abstract.php(466): Mage::dispatchEvent('admin_user_save...', Array)
#12 /home/app/code/core/Mage/Core/Model/Abstract.php(319): Mage_Core_Model_Abstract->_afterSave()
#13 /home/public_html/app/code/core/Mage/Adminhtml/controllers/Permissions/UserController.php(141): Mage_Core_Model_Abstract->save()
#14 /home/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Permissions_UserController->saveAction()
#15 /home/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('save')
#16 /home/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#17 /home/public_html/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#18 /home/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#19 /home/public_html/index.php(83): Mage::run('', 'store')
#20 {main}
答案 0 :(得分:0)
您的数据库完整性搞砸了。如果有人在关闭外键检查的情况下直接在db内创建或删除了用户或获得了权限,则可能会发生这种情况。
答案 1 :(得分:0)
从服务器删除该表并重新导入该表的备份版本。 外键约束最有可能被破坏/损坏,因此需要替换。
存在导致上述问题的ID重复。