Releases: salemaljebaly/mstore-api-optimizer
Release list
v1.1.0
Summary
Adds smart caching for product search queries, reducing response times from 2-5 seconds to <1ms for cached results - a good performance improvement it's about 60 %.
Problem
- Product searches hitting database every time
- 2-5 second response times for all searches
- Poor user experience, especially on slow networks
Solution
- Cache search results using WordPress Transients API
- Smart expiration: 5-30 min based on search term length
- Auto-clear cache when products are updated
- Zero mobile app changes needed
Performance
| Scenario | Before | After |
|---|---|---|
| First search | 2-5s | 2-3s |
| Cached search | 2-5s | <1ms ⚡ |
| Popular searches | Always slow | Always instant |
Changes
- Added 5 new methods (~180 lines) to
mstore-api-optimizer.php - Updated README and CHANGELOG
- Added complete documentation guide
Testing
✅ Validated on production (riad.ly)
✅ Real searches with Arabic text
✅ Cache hits: 0.42ms - 3.87ms
✅ Auto-invalidation confirmed
Compatibility
- Fully backward compatible
- No breaking changes
v1.0.3
Problem
payment_methodssometimes returned 400 ("Failed to add X items") when an item was deleted or invalidated between the shipping and payment steps.shipping_methodshandled this gracefully, butpayment_methodswas strict, leading to poor UX at checkout.- Deleted/unpurchasable items could still affect shipping totals.
- Mobile app requires a flat list response; structured payloads risk breaking the UI.
Solution
-
payment_methods
- Removed hard-fail behavior for partial
add_to_cartfailures. - Always return a flat list with 200 status. If no valid items remain, return an empty array
[]. - Stock adjustments logged in session/debug without changing response schema.
- Removed hard-fail behavior for partial
-
Batch add hardening (applies to both endpoints)
- Skip and record deleted/trashed/unpublished/unpurchasable items.
- Treat them as
not_found(like out-of-stock) → excluded from totals and errors.
-
shipping_methods
- Now benefits from the same skip logic — deleted products no longer inflate totals.
-
Version bump →
1.0.2.
Impact
- No changes required in the mobile app (response shape preserved).
- Eliminates rare checkout failures caused by product deletion between steps.
- UX improvement: endpoints no longer block checkout with hard errors.
- If all items invalid →
payment_methodsreturns[](200) and app can prompt user to review cart.
- If all items invalid →
- Performance unchanged (batch adds + single totals pass).
Test Plan
- Normal cart → both endpoints return
200with valid lists. - Partial invalid → delete one cart item in WP Admin between steps → both endpoints return lists, deleted item skipped.
- All invalid → single-item cart deleted between steps →
payment_methodsreturns[] (200). - Debug logs show
MStore API Optimizer DEBUGtimings and stock adjustment entries.
Risk & Rollback
- Risk: Low (changes limited to two overridden endpoints + shared helper).
- Rollback: Revert changes in
web/app/plugins/mstore-api-optimizer/mstore-api-optimizer.php.
v1.0.2
Summary
Fixes critical inventory race condition issues by implementing graceful stock handling instead of throwing exceptions.
• Replace "Exception Failed to add 1 items" errors with auto-adjustment logic
• Remove out-of-stock items automatically from cart
• Adjust quantities to available amounts when stock is limited
• Return detailed stock adjustment data for mobile notifications
• Prevent negative inventory scenarios
Problem
Users experienced hard failures when clicking shipping methods due to inventory race conditions - one user adds items,
another purchases them, causing stock conflicts that threw exceptions.
Solution
Transform failures into graceful adjustments:
- Out of stock → Remove item
- Limited stock (want 5, have 2) → Adjust to 2
- Return adjustment details for user notifications
Test Plan
- Test with out-of-stock products
- Test with limited stock scenarios
- Test with multiple concurrent users
- Verify no negative inventory
- Confirm mobile app compatibility
Impact
- ✅ Eliminates cart failures for production users
- ✅ Maintains inventory integrity
- ✅ Backward compatible with existing mobile apps
- ✅ Enables better UX with stock notifications
v1.0.1
What This Fix Does
The autoload configuration issue is causing Composer to fail on some systems because:
The Problem
"autoload": {
"psr-4": {
"MStorePerformanceFix\\": "src/"
}
}
This tells Composer: "When someone uses classes with namespace MStorePerformanceFix, look for them in the src/ directory"
But the src/ directory doesn't exist in your package!
What Happens
- Your macOS/production: Composer is lenient, ignores the missing directory
- Your team's machines: Composer is strict, fails installation because src/ doesn't exist
The Fix
"autoload": {}
This removes the invalid autoload rule entirely.