Make WordPress Core

Changeset 10762


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/comment.php

    r10731 r10762  
    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 )
     
    15471554 * @subpackage Cache
    15481555 *
    1549  * @param int $id Comment ID to remove from cache
    1550  */
    1551 function clean_comment_cache($id) {
    1552     wp_cache_delete($id, 'comment');
     1556 * @param int|array $id Comment ID or array of comment IDs to remove from cache
     1557 */
     1558function clean_comment_cache($ids) {
     1559    foreach ( (array) $ids as $id )
     1560        wp_cache_delete($id, 'comment');
    15531561}
    15541562
Note: See TracChangeset for help on using the changeset viewer.