fix: performance and security audit fixes#519
Conversation
- Fix O(n²) nested loop in Orders::order_item_after_calculate_taxes - Remove save_meta_data() from order/product/variation response hooks (was re-reading all meta from DB on every API response) - Move UUID persistence into maybe_add_post_uuid (only saves when needed) - Mask auth tokens in test endpoint (return length instead of value) - Protect temp template directory with .htaccess and index.php - Remove dead barcode field code in Products_Controller
📝 WalkthroughWalkthroughThis PR changes metadata handling across API controllers (parsing instead of saving), persists UUID metadata immediately, refactors order tax item iteration, adds temp-template directory protection files, and updates auth tests to assert token lengths rather than raw values. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 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)
No actionable comments were generated in the recent review. 🎉 Comment |
E2E API Test Results35 tests 35 ✅ 3s ⏱️ Results for commit bb4364a. ♻️ This comment has been updated with latest results. |
Address CodeRabbit feedback: check for .htaccess and index.php on every call, not just when creating the directory. Handles upgrades from older versions where the directory exists without protection files.
Summary
Orders::order_item_after_calculate_taxes— inner foreach used same$metavariable, shadowing outer loop and causing quadratic iterationsave_meta_data()from order/product/variation REST response hooks — this was callingread_meta_data(true)internally, re-reading ALL meta from the database for every single API response (root cause of 768MB memory exhaustion on large stores)maybe_add_post_uuid()sosave_meta_data()only runs when a UUID is actually generated, not on every response/wcpos/v1/jwt/authorizetest endpoint — return string length instead of raw token valueswp-uploads/wcpos-templates/) with.htaccessdeny andindex.phpguard$fields_to_searchvariable inProducts_ControllerTest plan
/wcpos/v1/jwt/authorizetest endpoint with a Bearer token — verify response containsheader_length(integer) instead ofheader_value(string)🤖 Generated with Claude Code
Summary by CodeRabbit
Security
Improvements
Bug Fixes
Tests