Please give us a description of what happened
When using the "Rewrite & Republish" feature, duplicate posts occasionally remain in the database with post_status = 'dp-rewrite-republish' instead of being deleted after the republishing process completes. These orphaned copies are not visible in the WordPress admin post list (by design, since show_in_admin_all_list is false), but they remain in the database indefinitely.
Key observations:
- The republishing process itself succeeds - the original post is updated correctly with the new content
- However, the cleanup process that should delete the duplicate copy does not execute
- This appears to happen when the redirect after republishing is interrupted before the cleanup can run
Root cause analysis:
The plugin uses a two-stage HTTP request architecture:
- First request: Execute republish + send redirect response
- Second request: Load redirect destination + execute cleanup via
clean_up_after_redirect()
The cleanup depends on the second request successfully loading, which can fail due to:
- User closes browser/tab before redirect completes
- Network interruption or timeout
- Nonce expiration (24-hour default)
- Session timeout
Database evidence:
We found 4 orphaned copies, all several months old, with their original posts successfully published:
SELECT
p.ID as copy_id,
p.post_title as copy_title,
p.post_status as copy_status,
pm_original.meta_value as original_id,
orig.post_status as original_status
FROM wp_2_posts p
LEFT JOIN wp_2_postmeta pm_original ON p.ID = pm_original.post_id
AND pm_original.meta_key = '_dp_original'
LEFT JOIN wp_2_posts orig ON pm_original.meta_value = orig.ID
WHERE p.post_status = 'dp-rewrite-republish'
| copy_id |
copy_status |
original_id |
original_status |
post_modified |
| 12447 |
dp-rewrite-republish |
76 |
publish |
2025-07-18 14:56:48 |
| 12318 |
dp-rewrite-republish |
169 |
publish |
2025-07-02 14:04:08 |
| 12236 |
dp-rewrite-republish |
105 |
publish |
2025-06-24 09:59:04 |
| 12141 |
dp-rewrite-republish |
205 |
publish |
2025-06-16 16:36:57 |
To Reproduce
Step-by-step reproduction instructions
This issue is difficult to reproduce consistently as it depends on timing and interruption. However, the following steps may trigger it:
Case 1: User interruption during redirect
- Create a "Rewrite & Republish" copy of a published post
- Edit the copy and click "Publish"
- Immediately after clicking publish (before the redirect completes):
- Close the browser tab, OR
- Navigate away from the page, OR
- Interrupt the network connection
- Check the database for posts with
post_status = 'dp-rewrite-republish'
Case 2: Long-running republish process (Most likely scenario)
This is particularly reproducible with posts that have many ACF (Advanced Custom Fields) fields:
- Create a post with many ACF fields (e.g., 20+ custom fields with repeaters, flexible content, etc.)
- Create a "Rewrite & Republish" copy
- Edit the copy and click "Publish"
- The republish process takes a long time to update all ACF meta fields (potentially 10-30+ seconds)
- During this waiting period, the user may:
- Assume the process hung and close the tab
- Navigate away thinking the save failed
- Click browser back button
- Close the browser
- The republish completes server-side, but the cleanup never runs because the redirect wasn't followed
Note: In our environment, all 4 orphaned copies were custom post types with extensive ACF field configurations, supporting this as the primary reproduction scenario.
Case 3: Nonce expiration
- Create a "Rewrite & Republish" copy
- Edit the copy and click "Publish"
- Wait more than 24 hours (or until nonce expires)
- The cleanup process will fail nonce verification
Expected results
- The duplicate copy should be deleted from the database after republishing completes
- The original post should be updated with the new content
- The
_dp_has_rewrite_republish_copy meta should be removed from the original post
- No posts with
post_status = 'dp-rewrite-republish' should remain in the database
Actual results
- The original post is updated correctly (republish succeeds)
- However, the duplicate copy remains in the database with
post_status = 'dp-rewrite-republish'
- The
_dp_has_rewrite_republish_copy meta may remain on the original post
- The orphaned copies are invisible in the admin UI but consume database space
- No error message is shown to the user
Screenshots, screen recording, code snippet
Relevant code sections:
The cleanup process in src/post-republisher.php:213-227:
public function clean_up_after_redirect() {
if ( ! empty( $_GET['dprepublished'] ) && ! empty( $_GET['dpcopy'] ) && ! empty( $_GET['post'] ) ) {
$copy_id = \intval( \wp_unslash( $_GET['dpcopy'] ) );
$post_id = \intval( \wp_unslash( $_GET['post'] ) );
\check_admin_referer( 'dp-republish', 'dpnonce' );
if ( \intval( \get_post_meta( $copy_id, '_dp_has_been_republished', true ) ) === 1 ) {
$this->delete_copy( $copy_id, $post_id );
}
else {
\wp_die( \esc_html__( 'An error occurred while deleting the Rewrite & Republish copy.', 'duplicate-post' ) );
}
}
}
This cleanup is hooked to load-post.php and only runs if the redirect destination loads successfully with the correct URL parameters.
Technical info
- If relevant, which editor is affected (or editors):
- Which browser is affected (or browsers):
Used versions
- Device you are using: Server environment (issue occurs server-side)
- Operating system: Linux
- PHP version: 8.2
- WordPress version: 6.6.2
- WordPress Theme: Custom theme
- Yoast Duplicate Post version: 5.2.0
- Classic Editor plugin version: 1.6.5
- Relevant plugins in case of a bug: WordPress multi-site installation with custom post types, Advanced Custom Fields (ACF) Pro with extensive field configurations
Please give us a description of what happened
When using the "Rewrite & Republish" feature, duplicate posts occasionally remain in the database with
post_status = 'dp-rewrite-republish'instead of being deleted after the republishing process completes. These orphaned copies are not visible in the WordPress admin post list (by design, sinceshow_in_admin_all_listisfalse), but they remain in the database indefinitely.Key observations:
Root cause analysis:
The plugin uses a two-stage HTTP request architecture:
clean_up_after_redirect()The cleanup depends on the second request successfully loading, which can fail due to:
Database evidence:
We found 4 orphaned copies, all several months old, with their original posts successfully published:
To Reproduce
Step-by-step reproduction instructions
This issue is difficult to reproduce consistently as it depends on timing and interruption. However, the following steps may trigger it:
Case 1: User interruption during redirect
post_status = 'dp-rewrite-republish'Case 2: Long-running republish process (Most likely scenario)
This is particularly reproducible with posts that have many ACF (Advanced Custom Fields) fields:
Note: In our environment, all 4 orphaned copies were custom post types with extensive ACF field configurations, supporting this as the primary reproduction scenario.
Case 3: Nonce expiration
Expected results
_dp_has_rewrite_republish_copymeta should be removed from the original postpost_status = 'dp-rewrite-republish'should remain in the databaseActual results
post_status = 'dp-rewrite-republish'_dp_has_rewrite_republish_copymeta may remain on the original postScreenshots, screen recording, code snippet
Relevant code sections:
The cleanup process in
src/post-republisher.php:213-227:This cleanup is hooked to
load-post.phpand only runs if the redirect destination loads successfully with the correct URL parameters.Technical info
Used versions