mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Reparent children when deleting a comment. Props vladimir_kolesnikov. fixes #9003
git-svn-id: http://svn.automattic.com/wordpress/trunk@10762 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
dd98e4f40f
commit
45e76b1b55
@ -739,6 +739,13 @@ function wp_delete_comment($comment_id) {
|
||||
if ( ! $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id) ) )
|
||||
return false;
|
||||
|
||||
// Move children up a level.
|
||||
$children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment_id) );
|
||||
if ( !empty($children) ) {
|
||||
$wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment_id));
|
||||
clean_comment_cache($children);
|
||||
}
|
||||
|
||||
$post_id = $comment->comment_post_ID;
|
||||
if ( $post_id && $comment->comment_approved == 1 )
|
||||
wp_update_comment_count($post_id);
|
||||
@ -1546,10 +1553,11 @@ function weblog_ping($server = '', $path = '') {
|
||||
* @package WordPress
|
||||
* @subpackage Cache
|
||||
*
|
||||
* @param int $id Comment ID to remove from cache
|
||||
* @param int|array $id Comment ID or array of comment IDs to remove from cache
|
||||
*/
|
||||
function clean_comment_cache($id) {
|
||||
wp_cache_delete($id, 'comment');
|
||||
function clean_comment_cache($ids) {
|
||||
foreach ( (array) $ids as $id )
|
||||
wp_cache_delete($id, 'comment');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user