@@ -427,6 +427,8 @@ function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookie
427427 }
428428 }
429429
430+ qa_question_uncache ($ oldquestion ['postid ' ]); // remove hidden posts immediately
431+
430432 $ eventparams = array (
431433 'postid ' => $ oldquestion ['postid ' ],
432434 'parentid ' => $ oldquestion ['parentid ' ],
@@ -617,6 +619,18 @@ function qa_post_unindex($postid)
617619}
618620
619621
622+ /**
623+ * Delete the cache for a question. Used after it or its answers/comments are hidden, to prevent them remaining visible to visitors/search engines.
624+ * @param int $questionId Post ID to delete.
625+ * @return bool
626+ */
627+ function qa_question_uncache ($ questionId )
628+ {
629+ $ cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver ();
630+ return $ cacheDriver ->delete ("question: $ questionId " );
631+ }
632+
633+
620634/**
621635 * Change the fields of an answer (application level) to $content, $format, $notify and $name, then reindex based on
622636 * $text. For backwards compatibility if $name is null then the name will not be changed. Pass the answer's database
@@ -801,6 +815,8 @@ function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid,
801815 }
802816 }
803817
818+ qa_question_uncache ($ question ['postid ' ]); // remove hidden posts immediately
819+
804820 $ eventparams = array (
805821 'postid ' => $ oldanswer ['postid ' ],
806822 'parentid ' => $ oldanswer ['parentid ' ],
@@ -1182,6 +1198,8 @@ function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid
11821198 $ oldcomment ['format ' ], qa_viewer_text ($ oldcomment ['content ' ], $ oldcomment ['format ' ]), null , $ oldcomment ['categoryid ' ]);
11831199 }
11841200
1201+ qa_question_uncache ($ question ['postid ' ]); // remove hidden posts immediately
1202+
11851203 $ eventparams = array (
11861204 'postid ' => $ oldcomment ['postid ' ],
11871205 'parentid ' => $ oldcomment ['parentid ' ],
0 commit comments