Commit 8b22a9bf by Scott

Clear cache when posts are hidden

parent 0f7262d2
......@@ -427,6 +427,8 @@ function qa_question_set_status($oldquestion, $status, $userid, $handle, $cookie
}
}
qa_question_uncache($oldquestion['postid']); // remove hidden posts immediately
$eventparams = array(
'postid' => $oldquestion['postid'],
'parentid' => $oldquestion['parentid'],
......@@ -618,6 +620,18 @@ function qa_post_unindex($postid)
/**
* Delete the cache for a question. Used after it or its answers/comments are hidden, to prevent them remaining visible to visitors/search engines.
* @param int $questionId Post ID to delete.
* @return bool
*/
function qa_question_uncache($questionId)
{
$cacheDriver = Q2A_Storage_CacheFactory::getCacheDriver();
return $cacheDriver->delete("question:$questionId");
}
/**
* Change the fields of an answer (application level) to $content, $format, $notify and $name, then reindex based on
* $text. For backwards compatibility if $name is null then the name will not be changed. Pass the answer's database
* record before changes in $oldanswer, the question's in $question, and details of the user doing this in $userid,
......@@ -801,6 +815,8 @@ function qa_answer_set_status($oldanswer, $status, $userid, $handle, $cookieid,
}
}
qa_question_uncache($question['postid']); // remove hidden posts immediately
$eventparams = array(
'postid' => $oldanswer['postid'],
'parentid' => $oldanswer['parentid'],
......@@ -1182,6 +1198,8 @@ function qa_comment_set_status($oldcomment, $status, $userid, $handle, $cookieid
$oldcomment['format'], qa_viewer_text($oldcomment['content'], $oldcomment['format']), null, $oldcomment['categoryid']);
}
qa_question_uncache($question['postid']); // remove hidden posts immediately
$eventparams = array(
'postid' => $oldcomment['postid'],
'parentid' => $oldcomment['parentid'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment