Repository navigation
Add null check in get_field_value_for_new_entry - #3570
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 1
✨ Finishing Touches
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 |
|
|
Overall Grade |
Security Reliability Complexity Hygiene |
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| PHP | Oct 13, 2026 6:13p.m. | Review ↗ | |
| JavaScript | Oct 13, 2026 6:13p.m. | Review ↗ |
Important
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
There was a problem hiding this comment.
Approve. The fix does what it says and changes nothing else.
Bug reproduced, before and after (local WP Playground, PHP 8.5.10, E_ALL + display_errors). I made a form with four fields whose default_value is NULL in the DB (text, email, textarea, select) and ran FrmFormsController::get_form_shortcode() on it.
- Base (
518b4aeb):Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in FrmEntriesHelper.php on line 137. - This PR (
592d879c): no deprecation. The output HTML is identical to base apart from the deprecation's own<br />and a random honeypot id.
Old vs new behavior, every input type (php run against copies of both versions): null, '', '0', 'Hello', 'He said "hi"', ['a','b'], [] all return the same value as before. The only difference is that null no longer raises the deprecation. The array branch's ?? '' is a no-op, so nothing is lost there.
CI. Most analysis jobs are skipped on this draft; Psalm, typos and the third-party checks pass. I did not run PHPUnit locally. I read the diff by hand rather than running code-review/security-review, since it is three lines in one function with no security surface. This is the only str_replace() on a possibly-null default in that function, so there is no sibling instance to patch.
Not exercised: no browser or screenshot check, because there is no visual change (the HTML output is identical). Submitting the form and the posted-value path were not run; they are unchanged by this diff.
No findings.
Supersedes #3332.
We don't typically type cast
null, but prefer checks instead.