Ticket #26042: 26042.4.diff
File 26042.4.diff, 1.8 KB (added by , 11 years ago) |
---|
-
src/wp-includes/revision.php
371 371 if ( ! $post || empty( $post->ID ) ) 372 372 return array(); 373 373 374 $defaults = array( 'order' => ' DESC', 'orderby' => 'date ID', 'check_enabled' => true );374 $defaults = array( 'order' => 'ASC', 'orderby' => 'date ID', 'check_enabled' => true ); 375 375 $args = wp_parse_args( $args, $defaults ); 376 376 377 377 if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) ) … … 382 382 if ( ! $revisions = get_children( $args ) ) 383 383 return array(); 384 384 385 $revisions = array_reverse( $revisions ); 386 385 387 return $revisions; 386 388 } 387 389 -
tests/phpunit/tests/post/revisions.php
338 338 $this->assertTrue( user_can( $author_user_id, 'read_post', $revision->ID ) ); 339 339 } 340 340 } 341 342 /** 343 * @ticket 26042 344 */ 345 function test_revision_order() { 346 $ok = 0; 347 $reversed = 0; 348 349 for ( $i = 0; $i < 100; $i++ ) { 350 $post_id = $this->factory->post->create( array( 'post_title' => 'some-post', 'post_type' => 'post', 'post_content' => 'some_content' ) ); 351 352 for ( $j = 1; $j < 3; $j++ ) { 353 wp_update_post( array( 'post_content' => 'updated post' . $j , 'ID' => $post_id ) ); 354 } 355 356 $revisions = wp_get_post_revisions( $post_id ); 357 $first = array_shift( $revisions ); 358 $last = array_pop( $revisions ); 359 360 if ( $first->ID < $last->ID ) { 361 $reversed++; 362 } else { 363 $ok++; 364 } 365 } 366 367 $this->assertEquals( 100, $ok ); 368 $this->assertEquals( 0, $reversed ); 369 } 341 370 }