Make WordPress Core


Ignore:
Timestamp:
03/10/2009 07:03:03 PM (16 years ago)
Author:
ryan
Message:

Reparent children when deleting a comment. Props vladimir_kolesnikov. fixes #9003 for 2.7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.7/wp-includes/comment.php

    r10454 r10763  
    740740        return false;
    741741
     742    // Move children up a level.
     743    $children = $wpdb->get_col( $wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_parent = %d", $comment_id) );
     744    if ( !empty($children) ) {
     745        $wpdb->update($wpdb->comments, array('comment_parent' => $comment->comment_parent), array('comment_parent' => $comment_id));
     746        clean_comment_cache($children);
     747    }
     748
    742749    $post_id = $comment->comment_post_ID;
    743750    if ( $post_id && $comment->comment_approved == 1 )
     
    15431550 * @subpackage Cache
    15441551 *
    1545  * @param int $id Comment ID to remove from cache
    1546  */
    1547 function clean_comment_cache($id) {
    1548     wp_cache_delete($id, 'comment');
     1552 * @param int|array $id Comment ID or array of comment IDs to remove from cache
     1553 */
     1554function clean_comment_cache($ids) {
     1555    foreach ( (array) $ids as $id )
     1556        wp_cache_delete($id, 'comment');
    15491557}
    15501558
Note: See TracChangeset for help on using the changeset viewer.