fix: preserve slashes for woocommerce product duplicate - #3731
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughA WooCommerce duplication hook detects Stackable blocks in duplicated product descriptions and reapplies WordPress slashing before WooCommerce saves the duplicate. ChangesWooCommerce duplicate escaping
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
🤖 Pull request artifacts
|
|
Size Change: +358 B (+0.01%) Total Size: 2.63 MB 📦 View Changed
ℹ️ View Unchanged
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/compatibility/woocommerce.php (1)
70-85: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDrop the unused
$productparameter (optional).PHPMD flags
$productas unused. Since only$duplicateis read, you can register withaccepted_args = 1and drop the second parameter to silence the warning.♻️ Optional simplification
- function stackable_preserve_woocommerce_duplicate_block_escaping( $duplicate, $product ) { + function stackable_preserve_woocommerce_duplicate_block_escaping( $duplicate ) { $description = $duplicate->get_description( 'edit' ); if ( strpos( $description, '<!-- wp:stackable/' ) !== false ) { $duplicate->set_description( wp_slash( $description ) ); } } add_action( 'woocommerce_product_duplicate_before_save', 'stackable_preserve_woocommerce_duplicate_block_escaping', 999999, - 2 + 1 );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/compatibility/woocommerce.php` around lines 70 - 85, Update stackable_preserve_woocommerce_duplicate_block_escaping to remove the unused $product parameter, and change its woocommerce_product_duplicate_before_save registration to accept one argument instead of two while preserving the existing duplicate-description handling.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/compatibility/woocommerce.php`:
- Around line 70-85: Update
stackable_preserve_woocommerce_duplicate_block_escaping to remove the unused
$product parameter, and change its woocommerce_product_duplicate_before_save
registration to accept one argument instead of two while preserving the existing
duplicate-description handling.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c7aeb644-0619-4d41-9d83-eb1550ed17c8
📒 Files selected for processing (1)
src/compatibility/woocommerce.php
Avoid a PHP 8 TypeError from strpos() when WooCommerce returns a non-string description during product duplication. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary by CodeRabbit