lol768 / XenForo-MCASSOC

Minecraft association addon for XenForo
Other
20 stars 9 forks source link

cant delete users #20

Closed ArcLP closed 8 years ago

ArcLP commented 8 years ago

Mysqli statement execute error : Cannot delete or update a parent row: a foreign key constraint fails (databasename.xf_association_mc, CONSTRAINT xf_association_mc_ibfk_1 FOREIGN KEY (xenforo_id) REFERENCES xf_user (user_id))

Zend_Db_Statement_Mysqli->_execute() in Zend/Db/Statement.php at line 297 Zend_Db_Statement->execute() in Zend/Db/Adapter/Abstract.php at line 479 Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 661 Zend_Db_Adapter_Abstract->delete() in XenForo/DataWriter.php at line 1839 XenForo_DataWriter->_delete() in XenForo/DataWriter.php at line 1792 XenForo_DataWriter->delete() in XenForo/Model/UserConfirmation.php at line 200 XenForo_Model_UserConfirmation->processUserModeration() in XenForo/ControllerAdmin/User.php at line 947 XenForo_ControllerAdmin_User->actionModeratedUpdate() in XenForo/FrontController.php at line 351 XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134 XenForo_FrontController->run() in /var/www/html/admin.php at line 13

what do?

lol768 commented 8 years ago

Does XenForo actually remove rows from the xf_user table when you delete a user?

ArcLP commented 8 years ago

It should. I don't know if it does currently. I'm no expert with mysql databases.

All I tried to do was deny a guy who got stopped by the moderated user thing.

the admincp said to either ignore, accept, or deny said user trying to register.

lol768 commented 8 years ago

It's unfortunate XenForo works in this way though, we'll lose a data integrity guarantee if I remove the FKC, which would be a shame - it might be inevitable though. Failing that, perhaps I can remove the association record first when you try and delete a user, which would also solve the problem.

I'll look into it tonight.

ArcLP commented 8 years ago

Xenforo is a douche sometimes. (I'm joking Xenforo don't read this kill me pls)

Thank you for looking into it, I apologize for this hassle. Just wanted to let you know/help you out. Thank you very much for reading this.

ArcLP commented 8 years ago

Also this might be useless but here is more information on it if you need;

Zend_Db_Statement_Mysqli_Exception: Mysqli statement execute error : Cannot delete or update a parent row: a foreign key constraint fails (database name.xf_association_mc, CONSTRAINT xf_association_mc_ibfk_1 FOREIGN KEY (xenforo_id) REFERENCES xf_user (user_id)) - library/Zend/Db/Statement/Mysqli.php:214 Generated By: Arc, 56 minutes ago

Stack Trace

0 /var/www/html/library/Zend/Db/Statement.php(297): Zend_Db_Statement_Mysqli->_execute(Array)

1 /var/www/html/library/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)

2 /var/www/html/library/Zend/Db/Adapter/Abstract.php(661): Zend_Db_Adapter_Abstract->query('DELETE FROM `xf...')

3 /var/www/html/library/XenForo/DataWriter.php(1839): Zend_Db_Adapter_Abstract->delete('xf_user', '(user_id = 4230...')

4 /var/www/html/library/XenForo/DataWriter.php(1792): XenForo_DataWriter->_delete()

5 /var/www/html/library/XenForo/Model/UserConfirmation.php(200): XenForo_DataWriter->delete()

6 /var/www/html/library/XenForo/ControllerAdmin/User.php(947): XenForo_Model_UserConfirmation->processUserModeration(Array, 'reject', true, 'Alternate accou...')

7 /var/www/html/library/XenForo/FrontController.php(351): XenForo_ControllerAdmin_User->actionModeratedUpdate()

8 /var/www/html/library/XenForo/FrontController.php(134): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))

9 /var/www/html/admin.php(13): XenForo_FrontController->run()

10 {main}

lol768 commented 8 years ago

Thanks for that. Just to update on this issue, it might have to be the weekend before I can look properly at it.

In the meantime if you need a workaround, you can manually disassociate the user from the ACP and then try to "re-deny" them.

ArcLP commented 8 years ago

Hey, any update? Found out I can't merge users. :P

Server Error

Mysqli statement execute error : Cannot delete or update a parent row: a foreign key constraint fails (databasename.xf_association_mc, CONSTRAINT xf_association_mc_ibfk_1 FOREIGN KEY (xenforo_id) REFERENCES xf_user (user_id))

Zend_Db_Statement_Mysqli->_execute() in Zend/Db/Statement.php at line 297 Zend_Db_Statement->execute() in Zend/Db/Adapter/Abstract.php at line 479 Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 661 Zend_Db_Adapter_Abstract->delete() in XenForo/DataWriter.php at line 1839 XenForo_DataWriter->_delete() in XenForo/DataWriter.php at line 1792 XenForo_DataWriter->delete() in XenForo/Model/User.php at line 3082 XenForo_Model_User->mergeUsers() in XenForo/ControllerAdmin/User.php at line 645 XenForo_ControllerAdmin_User->actionMerge() in XenForo/FrontController.php at line 351 XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134 XenForo_FrontController->run() in /var/www/html/admin.php at line 13

lol768 commented 8 years ago

@ArcLP Sorry for the delay, work has a way of sucking away free time! Thanks for the reminder.

I've looked into this and it would seem that XenForo do not use foreign keys anywhere in their codebase. Yay for data integrity!

I'm going to add an override for the _preDelete function on the XenForo_DataWriter_User class to try and work around this. I'll update this issue when I'm done.

lol768 commented 8 years ago

39cb4fb11a0cfc469c52b6ade9ebb824f36caf8c

lol768 commented 8 years ago

@ArcLP Please try the version available at https://github.com/lol768/XenForo-MCASSOC/releases/tag/1.1 and report back. Thanks!

ArcLP commented 8 years ago

HEY. It worked! Thank you very much for fixing it. :) 👍 Do you want to close this or me?

Again, thank you deeply. you deserve a ton of reputation and credit <3

lol768 commented 8 years ago

Glad it fixed it, I'm happy to close :)

Thanks for the detailed report.

lol768 commented 8 years ago

@ArcLP Can you do me a favour? Which version of XF do you use? I'd like to update the list of compatible versions

ArcLP commented 8 years ago

1.5.5

lol768 commented 8 years ago

Cheers