Skip to content

Commit

Permalink
Merge pull request #218 from Yoast/DUPP-33-fix-scheduled-republish-bug
Browse files Browse the repository at this point in the history
DUPP-33 Fix scheduled republish bug
  • Loading branch information
karlijnbok authored Dec 16, 2021
2 parents cdfaebd + 36005a0 commit f565965
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/post-republisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ public function republish_scheduled_post( $copy ) {
return;
}

\kses_remove_filters();
$this->republish( $copy, $original_post );
\kses_init_filters();
$this->delete_copy( $copy->ID, $original_post->ID );
}

Expand Down Expand Up @@ -324,7 +326,7 @@ protected function republish_post_elements( $post, $original_post ) {
$_POST['ID'] = $original_post->ID;

// Republish the original post.
$rewritten_post_id = \wp_update_post( \wp_slash( $post_to_be_rewritten ) );
$rewritten_post_id = \wp_update_post( $post_to_be_rewritten );

if ( $rewritten_post_id === 0 ) {
\wp_die( \esc_html__( 'An error occurred while republishing the post.', 'duplicate-post' ) );
Expand Down
3 changes: 3 additions & 0 deletions tests/post-republisher-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ public function test_republish_scheduled_post() {
->once()
->andReturn( $original );

Monkey\Functions\expect( 'kses_remove_filters' );
Monkey\Functions\expect( 'kses_init_filters' );

$this->instance->expects( 'republish' )->with( $copy, $original )->once();
$this->instance->expects( 'delete_copy' )->with( $copy->ID, $original->ID )->once();

Expand Down

0 comments on commit f565965

Please sign in to comment.