Fix outdated permalinks in indexables#22930
Conversation
thijsoo
left a comment
There was a problem hiding this comment.
The only thing that could be changes is maybe using the helper. But otherwise looking at the rest of the code we use get_permalink often so its could also work.
3de9695 to
e7917c8
Compare
Pull Request Test Coverage Report for Build 111970befc403edb5a3508d599ed9fa88a3091feDetails
💛 - Coveralls |
There was a problem hiding this comment.
Pull request overview
This PR enables dynamic handling of WooCommerce product permalinks that have changed due to category reassignments, particularly addressing changes introduced in WooCommerce 10.5. The implementation detects permalink mismatches between the stored indexable and the current permalink, then purges and recalculates outdated permalinks to ensure meta tags, canonicals, and schema remain accurate.
Changes:
- Added permalink validation logic in
Front_End_Integrationto detect and update outdated product permalinks when the feature flag is enabled - Enhanced
Meta_Tags_Context_Memoizerto support clearing specific cache entries and added corresponding presentation memoizer clearing - Moved permalink generation logic from
Indexable_Post_Builderto a newPermalink_Helpermethod for better reusability - Extended
Indexable_Repository::reset_permalink()to support filtering by object ID
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/conditionals/dynamic-product-permalinks-conditional.php | Adds feature flag conditional for dynamic product permalinks |
| src/helpers/permalink-helper.php | Extracts post permalink generation into reusable helper method |
| src/builders/indexable-post-builder.php | Refactors to use Permalink_Helper instead of internal method |
| src/integrations/front-end-integration.php | Implements permalink validation and update logic with feature flag checks |
| src/integrations/woocommerce-product-category-permalink-integration.php | Adds conditional logic to restore legacy permalink behavior when feature flag is disabled |
| src/repositories/indexable-repository.php | Extends reset_permalink to accept object_id parameter |
| src/memoizers/meta-tags-context-memoizer.php | Adds presentation memoizer clearing and new clear_for_current_page method |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3985018 to
05506ae
Compare
…indexable builder
…e flag is enabled
05506ae to
05f6a98
Compare
| Indexable_Builder_Versions $versions, | ||
| Meta_Helper $meta | ||
| Meta_Helper $meta, | ||
| Permalink_Helper $permalink_helper |
There was a problem hiding this comment.
@leonidasmi This is a breaking change, which has now broken the Video plugin.
Please fix.
There was a problem hiding this comment.
You mean the WP tests of Video? If so, here's the PR that fixes it: https://github.com/Yoast/wpseo-video/pull/1177
There was a problem hiding this comment.
@leonidasmi Thanks ! Any idea when that will be merged ?
There was a problem hiding this comment.
No promises, but I'll push for it in tomorrow's standup, so this week probably
(feel free to quickly CR and merge though, if you need it merged ASAP, there's no real impact aside from tests)
There was a problem hiding this comment.
Well, it LGTM, but I'm no expert in the indexables ;-)
It is blocking me, but I still have enough other things I can do before that becomes an issue. Will keep an eye on it in the mean time.
Thanks.
There was a problem hiding this comment.
@jrfnl the offending video pr has been merged :)
There was a problem hiding this comment.
@thijsoo @leonidasmi Thanks for the quick turn-around! Should the changelog for this change be reclassified to "Other" ? (as it is a breaking change for code based integrations)
Context
Summary
This PR can be summarized in the following changelog entry:
Relevant technical choices:
Meta_Tags_Context_Memoizer::clear()function while not adding regression tests in the instructions (aside from the case where we use it, when purging product permalinks) because I have verified that the function is not used anywhere in our codebase.Test instructions
Test instructions for the acceptance test before the PR gets merged
This PR can be acceptance tested by following these steps:
Note: Unless told otherwise, all steps require enabling the feature flag:
define( 'YOAST_SEO_DYNAMIC_PRODUCT_PERMALINKS', true );WooCommerce fix
Without this PR:
With this PR:
With Woo SEO
With the feature flag disabled
More generic testing
http://example.com/post-example/http://example.com/post-example-newhttp://example.com/post-examplewpseo_headhook that this PR is adding to do that.Relevant test scenarios
Test instructions for QA when the code is in the RC
Impact check
This PR affects the following parts of the plugin, which may require extra testing:
permalinkcolumn of indexables. You just need to check indexables for object_type=post. Clean indexables between switching plugin version.Enable media pagessetting and then run SEOO. Find all indexables with object_sub_type=attachment and compare the permalinks with this PR/RC and without. Clean indexables between switching plugin versionadd_filter( 'wpseo_dynamic_permalinks_enabled', '__return_true' );snippetEnable media pagessetting both on and off, create a post with no feature image and an image in the content, check the frontend and confirm that theImageObjectnode is the same with this PR/RC and without.Other environments
[shopify-seo], added test instructions for Shopify and attached theShopifylabel to this PR.[yoast-doc-extension], added test instructions for Yoast SEO for Google Docs and attached theGoogle Docs Add-onlabel to this PR.Documentation
Quality assurance
grunt build:imagesand commited the results, if my PR introduces new images or SVGs.Innovation
innovationlabel.Fixes #