Try to cut back on calls to get option#2652
Conversation
|
Warning Rate limit exceeded@Crabcyborg has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 4 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughSingle-file changes in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
classes/models/FrmFormApi.php (1)
408-415: Clear memoized cache on reset.The
reset_cached()method deletes the persistent cache but doesn't clear$memoized_api_info. Subsequent calls toget_cached_option()will return stale memoized data instead of recognizing the cache was reset.Apply this diff to clear the memoized cache:
public function reset_cached() { + unset( self::$memoized_api_info[ $this->cache_key ] ); + if ( is_multisite() ) { delete_site_option( $this->cache_key ); } else { delete_option( $this->cache_key ); } $this->done_running(); }
🧹 Nitpick comments (1)
classes/models/FrmFormApi.php (1)
314-328: Smart optimization for concurrent request handling.The modified logic correctly allows using expired cache when an API request is in-flight, preventing redundant requests while maintaining version consistency. This is a solid improvement.
Minor nitpick: The comment on line 320 duplicates the one on line 313.
Consider removing the duplicate comment:
- // If the api call is running, we can use the expired cache. $version = FrmAppHelper::plugin_version();
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
classes/models/FrmFormApi.php(4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
classes/models/FrmFormApi.php (5)
classes/models/FrmInbox.php (1)
is_expired(243-245)classes/controllers/FrmFormTemplatesController.php (1)
is_expired(861-863)classes/models/FrmAddon.php (1)
is_running(1085-1087)classes/models/FrmForm.php (1)
get_option(1336-1341)classes/models/FrmField.php (1)
get_option(1486-1494)
🪛 GitHub Actions: Inspections
classes/models/FrmFormApi.php
[error] 1-1: PHP CS Fixer reported issue: blank_line_before_statement (1/492 files) in classes/models/FrmFormApi.php. Run './vendor/bin/php-cs-fixer fix' to apply fixes. Process exited with code 8.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Cypress
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: PHP 7.4 tests in WP trunk
- GitHub Check: PHP 7.4 tests in WP trunk
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: Cypress
🔇 Additional comments (3)
classes/models/FrmFormApi.php (3)
30-37: Well-structured memoization property.The static property is appropriately scoped and documented. The array initialization and indexing by cache key will effectively reduce redundant
get_optioncalls.
343-360: Effective memoization implementation.The early return pattern efficiently avoids redundant option lookups, and the multisite fallback logic is correctly preserved.
376-377: Memoization update looks good.Correctly updates the in-memory cache when setting the persistent cache.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
classes/models/FrmFormApi.php(3 hunks)
🧰 Additional context used
🪛 GitHub Actions: Inspections
classes/models/FrmFormApi.php
[error] 1-1: PHP-CS-Fixer: 1 issue found (blank_line_before_statement). Command: './vendor/bin/php-cs-fixer fix --dry-run --verbose'.
🪛 PHPMD (2.15.0)
classes/models/FrmFormApi.php
334-334: Avoid unused local variables such as '$key'. (undefined)
(UnusedLocalVariable)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: PHP 7.4 tests in WP trunk
- GitHub Check: Cypress
🔇 Additional comments (2)
classes/models/FrmFormApi.php (2)
305-319: LGTM! Cleaner expired-cache handling.The refactored logic improves readability by extracting the expiration check into
$is_expiredand properly short-circuits when the cache is still valid, avoiding unnecessaryis_running()calls.
364-366: Autoload logic is correct but always evaluates totruefor this class.Given that
set_cache_key()always sets$this->cache_keyto start with'frm_addons_l', thestrposcheck will always return0, making$autoloadalwaystrue. This is fine if you're being defensive for potential subclasses that overrideset_cache_key(). Otherwise, consider simplifying to justtrue.
Related ticket https://secure.helpscout.net/conversation/3168224965/244001
get_optionchecks for the request lock when the cached data is not expired.Pre-release
formidable-6.26.1b.zip