pr: [Nightly Fix] - Null Safety - Guard External Cache Interval#1
pr: [Nightly Fix] - Null Safety - Guard External Cache Interval#1jewel-claw wants to merge 1 commit intomasterfrom
Conversation
|
PR author is not in the allowed authors list. |
Review Summary by QodoFix null safety in external cache interval validation
WalkthroughsDescription• Fix null safety issue in external cache interval guards • Replace contradictory isset/AND logic with empty check • Prevent undefined index notices in cache helper functions • Remove trailing whitespace from file Diagramflowchart LR
A["Old Logic: isset AND dereference"] -->|"Contradictory condition"| B["Potential undefined notices"]
C["New Logic: empty check"] -->|"Safe guard"| D["Early return on empty interval"]
B -->|"Fix applied"| D
File Changes1. boot/ninja-tables-global-function.php
|
Code Review by Qodo
1. Unguarded settings array access
|
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Overview
AnalysisThe PR correctly fixes a logic bug in the original code:
The fix is valid and addresses a null safety issue in the external cache interval validation. Files Reviewed (1 file)
|
| if (empty($tableSettings['caching_interval'])) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
1. Unguarded settings array access 🐞 Bug ⛯ Reliability
ninjaTableGetExternalCachedData() and ninjaTableSetExternalCacheData() call empty($tableSettings['caching_interval']) immediately after get_post_meta() without verifying $tableSettings is an array. If _ninja_table_settings is missing/falsy/non-array, the array-offset access can throw PHP warnings/errors before the intended early return.
Agent Prompt
### Issue description
`ninjaTableGetExternalCachedData()` and `ninjaTableSetExternalCacheData()` use `empty($tableSettings['caching_interval'])` right after `get_post_meta()`. If `_ninja_table_settings` is missing/falsy/non-array, the array-offset access can error before the early-return executes.
### Issue Context
The codebase already treats `get_post_meta()` results as potentially falsy/non-array and normalizes settings to defaults in `ninja_table_get_table_settings()`. Also, default settings do not define `caching_interval`, so this key can be absent.
### Fix Focus Areas
- boot/ninja-tables-global-function.php[392-401]
- boot/ninja-tables-global-function.php[412-417]
### Implementation notes
Use one of:
- `if (!is_array($tableSettings) || empty($tableSettings['caching_interval'])) return false;`
- or replace `get_post_meta(... '_ninja_table_settings' ...)` with `ninja_table_get_table_settings(...)` (ensures an array), then `empty($tableSettings['caching_interval'])` is safe.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
What
caching_intervalis empty or missingWhy
caching_intervaleven when it was unset, which can trigger notices and skip the intended early returnFix
issetcheck with anemptyguard in both cache helper functionsConfidence
boot/ninja-tables-global-function.phpwithphp -l