[BUGFIX] TS settings may be empty#127
Conversation
e.g. when class is called in BE-Context
📝 WalkthroughWalkthrough
ChangesSettings Safety
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Classes/Domain/Model/FormElements/CaptchaElement.php`:
- Around line 33-38: The current assignment uses direct offsets on $settings
which can emit undefined-key warnings and drop defaults; update the logic in the
CaptchaElement code that sets showRefresh and showAudio to read each key with a
per-key fallback (e.g., use isset() or null coalescing on
$settings['refreshButton'] and $settings['audioButton']) and default them to
true when the keys are missing or null before calling
$this->setProperty('showRefresh', ...) and $this->setProperty('showAudio', ...).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e8e405c5-8c31-4d75-8643-970a26d13715
📒 Files selected for processing (1)
Classes/Domain/Model/FormElements/CaptchaElement.php
| $settings = $ts['plugin.']['tx_bwcaptcha.']['settings.'] ?? null; | ||
| if ($settings === null) { | ||
| return; | ||
| } | ||
| $this->setProperty('showRefresh', (bool)$settings['refreshButton']); | ||
| $this->setProperty('showAudio', (bool)$settings['audioButton']); |
There was a problem hiding this comment.
Preserve default button behavior when settings are partially missing.
Line 37 and Line 38 still use direct offsets, so a present-but-partial settings. array can trigger undefined-key warnings and silently drop defaults (refreshButton / audioButton should default to enabled). Use per-key fallbacks during assignment.
Suggested fix
- $settings = $ts['plugin.']['tx_bwcaptcha.']['settings.'] ?? null;
- if ($settings === null) {
- return;
- }
- $this->setProperty('showRefresh', (bool)$settings['refreshButton']);
- $this->setProperty('showAudio', (bool)$settings['audioButton']);
+ $settings = $ts['plugin.']['tx_bwcaptcha.']['settings.'] ?? [];
+ $this->setProperty('showRefresh', (bool)($settings['refreshButton'] ?? true));
+ $this->setProperty('showAudio', (bool)($settings['audioButton'] ?? true));📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| $settings = $ts['plugin.']['tx_bwcaptcha.']['settings.'] ?? null; | |
| if ($settings === null) { | |
| return; | |
| } | |
| $this->setProperty('showRefresh', (bool)$settings['refreshButton']); | |
| $this->setProperty('showAudio', (bool)$settings['audioButton']); | |
| $settings = $ts['plugin.']['tx_bwcaptcha.']['settings.'] ?? []; | |
| $this->setProperty('showRefresh', (bool)($settings['refreshButton'] ?? true)); | |
| $this->setProperty('showAudio', (bool)($settings['audioButton'] ?? true)); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Classes/Domain/Model/FormElements/CaptchaElement.php` around lines 33 - 38,
The current assignment uses direct offsets on $settings which can emit
undefined-key warnings and drop defaults; update the logic in the CaptchaElement
code that sets showRefresh and showAudio to read each key with a per-key
fallback (e.g., use isset() or null coalescing on $settings['refreshButton'] and
$settings['audioButton']) and default them to true when the keys are missing or
null before calling $this->setProperty('showRefresh', ...) and
$this->setProperty('showAudio', ...).
|
Hey @achimfritz, thanks! |
e.g. when class is called in BE-Context
Summary by CodeRabbit