Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
in Q2A Core by

I get an infinite loading when I try to delete a hidden post or to post an answer, I noticed that while I'm trying to delete directly through the database I get this error message:

 #1451 - Cannot delete or update a parent row: a foreign key constraint fails (`qa`.`qa_posts`, CONSTRAINT `qa_posts_ibfk_2` FOREIGN KEY (`parentid`) REFERENCES `qa_posts` (`postid`)) 

Q2A version: question2answer-1.8.6
You cannot delete a question if it has an answer or comment and similarly an answer if it has a comment.

2 Answers

0 votes
Your play with the db, may be you change the setting of your database, so create a new db , and change the name of db in qa-config.php , and... after that open your q2a site, after that import the old tables in new database, remember do not import whole db, only single table at a time.
+1 vote

If you modify the DB directly, you will not fire all the needed events needed to perform the expected action. That can either make the action fail, or make any other Q2A core or plugin feature fail. In other words, even if you don't detect you've broken something immediately, you might detect it at a later stage.

Conclusion: unless you know 100% of the Q2A core and plugin code that gets executed when performing a specific action, don't try to replicate it by modifying the database directly.

Having said so, there's a plugin that takes care of some (if not all) of these issues: https://github.com/amiyasahu/q2a-delete-hidden-posts

I checked error.log (I'm on xampp) and there's anything, there's maybe a specific error log file for question2answer?
It could be anything. From PHP errors not being logged in the server log file because of PHP configurations, to JavaScript errors that break the form submission, going through server issues and even you just opening the wrong log file. With no information on the issue chances to find the solution are negligible
In the end I solved it, checking the javascript console I noticed that the CSP set in the main domain blocks connections to the subdirectory where question2answer is installed, but the error only occurs when the button to send is pressed the answer and I never noticed it, now I have added the subdirectory in the whitelist and everything works fine, thanks for the help!
That's a server issue (as I said :P)