Ticket #6775: 6775.5.diff

File 6775.5.diff, 2.3 kB (added by mdawaffe, 7 months ago)

delete deleted post's revisions, constant for turning off revisions

  • wp-includes/post.php

    old new  
    957957                $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'page' ) ); 
    958958        } 
    959959 
     960        // Do raw query.  wp_get_post_revisions() is filtered 
     961        $revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) ); 
     962        // Use wp_delete_post (via wp_delete_revision) again.  Ensures any meta/misplaced data gets cleaned up. 
     963        foreach ( $revision_ids as $revision_id ) 
     964                wp_delete_revision( $revision_id ); 
     965 
    960966        // Point all attachments to this post up one level 
    961967        $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'attachment' ) ); 
    962968 
     
    30223028        if ( @constant( 'DOING_AUTOSAVE' ) ) 
    30233029                return; 
    30243030 
     3031        if ( !constant('WP_POST_REVISIONS') ) 
     3032                return; 
     3033 
    30253034        if ( !$post = get_post( $post_id, ARRAY_A ) ) 
    30263035                return; 
    30273036 
     
    32273236 * @return array empty if no revisions 
    32283237 */ 
    32293238function wp_get_post_revisions( $post_id = 0 ) { 
     3239        if ( !constant('WP_POST_REVISIONS') ) 
     3240                return array(); 
    32303241        if ( ( !$post = get_post( $post_id ) ) || empty( $post->ID ) ) 
    32313242                return array(); 
    32323243        if ( !$revisions = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) ) ) 
  • wp-settings.php

    old new  
    376376 
    377377do_action('plugins_loaded'); 
    378378 
     379$default_constants = array( 'WP_POST_REVISIONS' => true ); 
     380foreach ( $default_constants as $c => $v ) 
     381        @define( $c, $v ); // will fail if the constant is already defined 
     382unset($default_constants, $c, $v); 
     383 
    379384// If already slashed, strip. 
    380385if ( get_magic_quotes_gpc() ) { 
    381386        $_GET    = stripslashes_deep($_GET   ); 
  • wp-admin/revision.php

    old new  
    22 
    33require_once('admin.php'); 
    44 
     5if ( !constant('WP_POST_REVISIONS') ) { 
     6        wp_redirect( 'edit.php' ); 
     7        exit; 
     8} 
     9 
    510wp_reset_vars(array('revision', 'left', 'right', 'action')); 
    611$revision_id = absint($revision); 
    712$diff        = absint($diff);