WordPress.org

Make WordPress Core

Opened 5 months ago

Closed 5 months ago

#26219 closed defect (bug) (duplicate)

Tests_Post_Revisions::test_revision_dont_save_revision_if_unchanged unit test fails

Reported by: nunomorgadinho Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Unit Tests Keywords: has-patch
Focuses: Cc:

Description

This unit test is failing:

1) Tests_Post_Revisions::test_revision_dont_save_revision_if_unchanged
Failed asserting that actual size 4 matches expected size 3.

in tests/phpunit/tests/post/revisions.php:83

I've traced the problem down to wp-includes/revision.php line 95:

	if ( $revisions = wp_get_post_revisions( $post_id ) ) {
		// grab the last revision, but not an autosave
		foreach ( $revisions as $revision ) {
			if ( false !== strpos( $revision->post_name, "{$revision->post_parent}-revision" ) ) {
				$last_revision = $revision;
				break;
			}
		}

When creating the revisions programmatically it seems $last_revision is not fetched correctly. Since revisions are ordered I wonder if we could replace this code by one where we just grab the last revision out of the revisions array directly.

Attachments (1)

revisions.php.patch (891 bytes) - added by nunomorgadinho 5 months ago.

Download all attachments as: .zip

Change History (2)

comment:1 ocean905 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version trunk deleted

Duplicate of #26042.

Note: See TracTickets for help on using tickets.