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

When I try to delete an answer that has a related question that is hidden, I get the folloing message:

Question2Answer query failed:

DELETE FROM qa_posts WHERE postid=...

Error 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`))

I understand why the error occurs, but I think in this situation the delete link should not be shown (or, at least, the error message should provide some useful information).

1 Answer

0 votes
by

You're quite right - thanks for catching this!

The solution is to replace this line in qa-page-question.php:

case 'Q': // never show follow-on Qs which have been hidden, even to admins

... with ...

case 'Q': case 'Q_HIDDEN':

That should solve the problem, i.e. prevent the delete link being shown. It also means that a hidden related question wlll be visible to admins.

...