Make WordPress Core

Ticket #25545: 25545.2.diff

File 25545.2.diff, 1.6 KB (added by wonderboymusic, 10 years ago)
  • src/wp-includes/ms-functions.php

     
    277277                $reassign = (int) $reassign;
    278278                $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id) );
    279279                $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id) );
     280
     281                $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $reassign ) );
     282                array_map( 'clean_post_cache', $post_ids );
    280283        }
    281284
    282285        restore_current_blog();
  • tests/phpunit/tests/ms.php

     
    2525                $wpdb->suppress_errors( $this->suppress );
    2626        }
    2727
     28        function test_remove_user_from_blog() {
     29                $user1 = $this->factory->user->create_and_get();
     30                $user2 = $this->factory->user->create_and_get();
     31
     32                $post_id = $this->factory->post->create( array( 'post_author' => $user1->ID ) );
     33
     34                remove_user_from_blog( $user1->ID, 1, $user2->ID );
     35
     36                $post = get_post( $post_id );
     37
     38                $this->assertNotEquals( $user1->ID, $post->post_author );
     39                $this->assertEquals( $user2->ID, $post->post_author );
     40        }
     41
    2842        /**
    2943         * @ticket 22917
    3044         */
     
    11581172                // Expect 0 sites when using an offset larger than the number of sites
    11591173                $this->assertCount( 0, wp_get_sites( array( 'offset' => 20 ) ) );
    11601174        }
     1175
    11611176}
    11621177
    11631178endif;