Conversation
1cf36da to
5ca4e6c
Compare
Testing GuidelinesHi @albarin @senadir @woocommerce/flux, Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed. Reminder: PR reviewers are required to document testing performed. This includes:
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds WooCommerce cache-priming documentation and changelog entry; replaces runtime Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can use your project's `phpmd` ruleset to improve the quality of PHP code reviews.You can customize the |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
plugins/woocommerce/src/Blocks/Assets/AssetDataRegistry.php (1)
157-157: Filter invalid page IDs before priming post caches.Line 157 primes every value from
$store_pages, including sentinel values (0/-1) when a store page is unset. Filtering to positive IDs avoids unnecessary cache-priming queries.💡 Suggested change
- _prime_post_caches( array_values( $store_pages ), false, false ); + $page_ids_to_prime = array_filter( array_map( 'absint', array_values( $store_pages ) ) ); + if ( ! empty( $page_ids_to_prime ) ) { + _prime_post_caches( $page_ids_to_prime, false, false ); + }As per coding guidelines
**/*.{php,js,jsx,tsx,ts}: Guard all code against unexpected inputs.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@plugins/woocommerce/src/Blocks/Assets/AssetDataRegistry.php` at line 157, The code calls _prime_post_caches( array_values( $store_pages ), false, false ) in AssetDataRegistry but does not filter out sentinel/invalid IDs (0, -1), causing unnecessary cache queries; before calling _prime_post_caches, filter $store_pages to only include positive integers (e.g., array_filter with is_int/is_numeric and > 0 or casting to int) so only valid post IDs are passed to _prime_post_caches, leaving other logic and variable names ($store_pages, _prime_post_caches) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.ai/skills/woocommerce-performance/cache-priming.md:
- Around line 126-132: The example call to _prime_post_caches uses the wrong
boolean order relative to the comment: _prime_post_caches( $ids,
$update_term_cache = true, $update_meta_cache = true ). Update the example so it
actually skips meta priming and includes terms by swapping the booleans to
_prime_post_caches( $order_ids, true, false ), or alternatively, if you intended
to skip terms, adjust the comment to state that the call skips term priming;
reference the _prime_post_caches function and the $order_ids example when making
the change.
---
Nitpick comments:
In `@plugins/woocommerce/src/Blocks/Assets/AssetDataRegistry.php`:
- Line 157: The code calls _prime_post_caches( array_values( $store_pages ),
false, false ) in AssetDataRegistry but does not filter out sentinel/invalid IDs
(0, -1), causing unnecessary cache queries; before calling _prime_post_caches,
filter $store_pages to only include positive integers (e.g., array_filter with
is_int/is_numeric and > 0 or casting to int) so only valid post IDs are passed
to _prime_post_caches, leaving other logic and variable names ($store_pages,
_prime_post_caches) unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 918ce955-0703-49a6-b2ad-8b855b0611da
📒 Files selected for processing (22)
.ai/skills/woocommerce-performance/SKILL.md.ai/skills/woocommerce-performance/cache-priming.mdplugins/woocommerce/changelog/performance-extract-cache-priming-prs-into-skillplugins/woocommerce/includes/class-wc-cart-session.phpplugins/woocommerce/includes/class-wc-order-factory.phpplugins/woocommerce/includes/class-wc-product-factory.phpplugins/woocommerce/includes/class-wc-product-grouped.phpplugins/woocommerce/includes/class-wc-product-variable.phpplugins/woocommerce/includes/data-stores/class-wc-product-data-store-cpt.phpplugins/woocommerce/includes/data-stores/class-wc-product-grouped-data-store-cpt.phpplugins/woocommerce/includes/data-stores/class-wc-product-variable-data-store-cpt.phpplugins/woocommerce/includes/shortcodes/class-wc-shortcode-products.phpplugins/woocommerce/includes/wc-template-functions.phpplugins/woocommerce/phpstan-baseline.neonplugins/woocommerce/src/Blocks/Assets/AssetDataRegistry.phpplugins/woocommerce/src/Blocks/BlockTypes/AbstractProductGrid.phpplugins/woocommerce/src/Blocks/BlockTypes/RelatedProducts.phpplugins/woocommerce/src/Blocks/Utils/BlockTemplateUtils.phpplugins/woocommerce/src/Internal/Admin/ProductReviews/ReviewsUtil.phpplugins/woocommerce/src/Internal/RestApi/Routes/V4/Orders/Controller.phpplugins/woocommerce/src/StoreApi/Schemas/V1/CartSchema.phpplugins/woocommerce/src/StoreApi/Utilities/ProductQuery.php
💤 Files with no reviewable changes (1)
- plugins/woocommerce/phpstan-baseline.neon
Test using WordPress PlaygroundThe changes in this pull request can be previewed and tested using a WordPress Playground instance. Test this pull request with WordPress Playground. Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit. |
albarin
left a comment
There was a problem hiding this comment.
✅ Confirmed the skill and code changes both look good
|
Hi @kalessil! Your PR contains REST API changes. Please consider updating the REST API documentation if your changes affect the public API. Changed API files: |
Submission Review Guidelines:
Changes proposed in this Pull Request:
Building on my work from Q1 2026, I created a new skill for using cache priming in our codebase through my recent PRs. In this PR, I am adding the skill to the repository and using AI-assisted cleanup to standardize existing cache priming usages.
On the PHP side, this removes stale
is_callableguards, adds missing! empty()guards, and normalises comment text to// Prime caches to reduce future queries.How to test the changes in this Pull Request: