Add type check to avoid php warning#2018
Conversation
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Suggested labels
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
classes/controllers/FrmSimpleBlocksController.php (1)
55-55: Approve the type check addition with a minor suggestion.The added type check
is_array( $views_addon )effectively addresses the PR objective by preventing PHP warnings when accessing array offsets on non-array values. This change improves the code's robustness and aligns with the PR description.For improved clarity and to handle all potential cases, consider using the null coalescing operator:
- 'installed' => is_array( $views_addon ) && 'installed' === $views_addon['status']['type'], + 'installed' => 'installed' === ($views_addon['status']['type'] ?? ''),This change will return
falseif any part of the path ($views_addon,['status'], or['type']) is not set, without triggering any warnings.
Related ticket https://secure.helpscout.net/conversation/2723585835/211506
This just adds a small check in case the query for add-ons data fails and the views data is unavailable.