Skip to content

Network origin post update incorrectly updates published dates of distributed posts #233

@adamsilverstein

Description

@adamsilverstein

Description

Under Distributor 1.2.3, using a network/multisite configuration we are noticing that updating an origin post changes the published dates on remote posts. We noticed this issue because any time an origin post was updated on our network, the destination posts got a new current time published date and jumped to the top of the home page river which shows the most recent posts first. This seems like unexpected/buggy behavior, is this expected?

Steps to reproduce

  • Publish a post on site A
  • Distribute the post to site B
  • Edit the post on site B, changing the publication date to yesterday (this step is so you can see the bug, waiting some time also works)
  • Edit the post on site A, make a small change and click update. Distributor updates the copy of the post on site B
  • Edit the post on site B and note its "Published" date

Expected behavior

The destination post on site B should not have its published date changed - only the content should change when the original post is updated and it should stay in the same place in our reverse chronological post list.

Actual behavior

The destination post on site B had its published date updated to the time the update occurred (eg the current time), bring it to the top of our homepage.

Workaround

The following code will work around this issue using the dt_push_post_args filter - before pushing an update (the presence of the 'ID' field indicates this is an update) we pull the remote post's date and add that to the update arguments.

/**
 * When pushing posts, don't change the destination post date.
 */
function filter_dt_push_post( $post_body ) {
	if ( isset( $post_body['ID'] ) ) {
		$existing_date = date( 'Y-m-d H:i:s', get_post_time( 'U', false, (int) $post_body['ID'] ) );
		$post_body['post_date'] = $existing_date;
	}
	return $post_body;
}
add_filter( 'dt_push_post_args', __NAMESPACE__ . '\filter_dt_push_post', 10 );

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugSomething isn't working.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions