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

q2a 1.5.4

1. Question is marked as duplicate

2. Original (referenced from duplicate) is closed!

3. Trying to delete the duplicate question triggers the mysql error:

Question2Answer query failed:

DELETE FROM qa_posts WHERE postid=123

Error 1451: Cannot delete or update a parent row: a foreign key constraint fails (`db`.`qa_posts`, CONSTRAINT `qa_posts_ibfk_4` FOREIGN KEY (`closedbyid`) REFERENCES `qa_posts` (`postid`))

 

Solution for now:

+ Re-Open closed original question

+ Then delete duplicate(s)

+ close original again

Q2A version: 1.5.4
by
thank you...

1 Answer

+1 vote
by
Will be fixed in Q2A 1.6.
by
Hi gid, where what line(s) was changed to prevent this? ... I cannot update to 1.6 yet but'd like to get rid of this problem.
by
Towards the end of qa_page_q_post_rules(...) in qa-page-question-view.php - you'll have to compare the source code to find the exact line.
by
The only difference I see is that:

if (
    ($childpost['parentid']==$post['postid']) &&
    ( ($childpost['basetype']=='A') || ($childpost['basetype']=='C') )
) {

was replaced by:
if ($childpost['parentid']==$post['postid']) {

Is this the fix?
by
Yes I believe so.
...