From 9b7a2234c303c762a7f26edabed8469c1de62233 Mon Sep 17 00:00:00 2001 From: CHIP Date: Sat, 12 Sep 2026 17:58:11 +0200 Subject: [PATCH] Fix deprecated null value passed to str_replace in get_field_value_for_new_entry A field without a default value has a null default_value, and a field type whose value is not posted back leaves it null as well. Passing that null to str_replace() as the subject is deprecated in PHP 8.1+ and logs: Deprecated: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in classes/helpers/FrmEntriesHelper.php on line 132 It is visible on any form that has such a field while WP_DEBUG_DISPLAY is on. Casting before the call keeps the empty string the caller already received, so no behaviour changes: the same value is returned for null, an empty string, a plain string, and a string containing a quote. --- classes/helpers/FrmEntriesHelper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classes/helpers/FrmEntriesHelper.php b/classes/helpers/FrmEntriesHelper.php index bc1bbfff14..0f7fd232bb 100644 --- a/classes/helpers/FrmEntriesHelper.php +++ b/classes/helpers/FrmEntriesHelper.php @@ -128,8 +128,12 @@ private static function get_field_value_for_new_entry( $field, $reset, $args ) { self::get_posted_value( $field, $new_value, $args ); } + // A field with no default value has a null default_value, and a field type + // whose value is not posted back leaves it null too. str_replace() warns on + // a null subject in PHP 8.1+, so cast first: this keeps returning the empty + // string the caller already relied on. if ( ! is_array( $new_value ) ) { - return str_replace( '"', '"', $new_value ); + return str_replace( '"', '"', (string) $new_value ); } return $new_value;