fix: copy the sticky state when duplicating - #551
Open
faisalahammad wants to merge 1 commit into
Open
faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Sticky posts are tracked in the sticky_posts option instead of post fields, so neither duplication path carried the setting over. Now the duplicate is marked sticky when the original is a sticky post, in both the namespaced duplicator (Rewrite & Republish) and the legacy function used by Clone and New Draft. Fixes Yoast#371
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Issue #371 reports that the sticky setting is lost when a post is duplicated with Rewrite & Republish in the Classic Editor. The same happens with Clone and New Draft. Sticky state is stored in the
sticky_postsoption, not in post fields or post meta, so both duplication paths skip it.Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
sticky_postsoption, so it is copied explicitly withis_sticky()/stick_post()after the duplicate is inserted, in both the namespacedPost_Duplicator(Rewrite & Republish) and the legacyduplicate_post_create_duplicate()(Clone, New Draft, bulk actions).postpost type, sincestick_post()does not validate the post type but the sticky UI in core only exists for posts. This keeps duplicated pages, attachments and custom post types untouched.sticky_posts, and when the Rewrite & Republish copy is deleted, core's_reset_front_page_settings_for_post()removes its ID from the option, so no stale IDs are left behind.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
Relevant test scenarios
The reported issue is Classic Editor specific, so both Classic and block editor flows were checked (steps 3 and 7). Sticky is a posts-only feature, so pages and enabled custom post types were verified not to become sticky (step 6).
Test instructions for QA when the code is in the RC
QA can test this PR by following these steps:
Same steps as the acceptance test above.
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
Post_Duplicatorclass and the legacyduplicate_post_create_duplicate()function. Everything that does not involve thepostpost type is unaffected because of the post type guard.UI changes
Documentation
Quality assurance
Innovation
innovationlabel and noted the work hours.Note: I cannot attach labels as an outside contributor, so this PR still needs the
changelog: bugfixlabel.Fixes #371