fix: return only unique Author ID <=> Post Author (ID) pairings. #22065
+2
−0
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.
Because of the join across the
wp_posts
table, there could potentially be many posts where an author has been updated. Currently, each of those rows are returned but that data is discarded because theSELECT
statement only grabsauthor_id
<=>post_author
pairings. For large data sets, this leads to an extremely inflated data list of duplicatedauthor_id
<=>post_author
(ID) pairings.With the
GROUP BY
statement, we ensure that only uniqueauthor_id
<=>post_author
(ID) pairings are returned, leading to much more efficient operation (from a code standpoint).Context
See this issue: #22064
This PR makes the
update_indexables_author_to_reassigned
operation, and thewp yoast cleanup
operation, much more efficient, by tackling only the (Old) Author ID <=> (New) Post Author (ID) pairings that need to be processed.Summary
This PR can be summarized in the following changelog entry:
changelog: enhancement
Fixes an issue where running the
wp yoast cleanup
CLI command would hang when it reaches theupdate_indexables_author_to_reassigned
step (for very large data sets). The only way to fix this would be by manually deleting the rows that are returned by this query fromwp_yoast_indexable
table.*
Relevant technical choices:
Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
wp yoast index
wp yoast cleanup
. Notice that the command hangs at theupdate_indexables_author_to_reassigned
step.SELECT wp_yoast_indexable.author_id, wp_posts.post_author FROM wp_yoast_indexable JOIN wp_posts on wp_yoast_indexable.object_id = wp_posts.id WHERE object_type='post' AND wp_yoast_indexable.author_id <> wp_posts.post_author ORDER BY wp_yoast_indexable.author_id
. Notice that this query returns the same number of rows as the posts that you created.SELECT wp_yoast_indexable.author_id, wp_posts.post_author FROM wp_yoast_indexable JOIN wp_posts on wp_yoast_indexable.object_id = wp_posts.id WHERE object_type='post' AND wp_yoast_indexable.author_id <> wp_posts.post_author GROUP BY wp_yoast_indexable.author_id, wp_posts.post_author ORDER BY wp_yoast_indexable.author_id
. Notice that only 1 row is returned, indicating the Old Author ID being updated with the New Post Author ID.wp yoast cleanup
. Notice that the command runs without hanging.Relevant test scenarios
Please see test steps above for reasoning on selecting second choice.
Test instructions for QA when the code is in the RC
N/A
QA can test this PR by following these steps:
N/A
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
N/A
UI changes
Other environments
[shopify-seo]
, added test instructions for Shopify and attached theShopify
label to this PR.Documentation
Quality assurance
Innovation
innovation
label.Fixes #22064