Issue-863: PHP Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated #865
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Note: To minimize the impact on the rest of the Fieldmanager fields, this change is localized to the TextArea field, since that appears to be where the issue is occurring.
Fixes Issue
PHP Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated
Description of Change
To address the issue of PHP deprecation errors when a
default_value
field is not set and defaults tonull
, we have modified the logic in the printing of fields within the WP admin area. Specifically, in scenarios where a default value is not set, which leads to anull
return value, a ternary operation or a direct assignment now ensures thatesc_textarea
receives an empty string instead ofnull
. This change preventshtmlspecialchars()
from throwing a deprecation notice due to receiving anull
value.The modification was implemented in the handling of default values within the
Fieldmanager_TextArea
class to circumvent the deprecation notice. It's crucial to emphasize that the default behavior for handling default values remains unaltered to prevent unintended side effects in other areas of the application.Use Case Affected
This change impacts any site using fields that extend
Fieldmanager_TextArea
, specifically in scenarios where thedefault_value
is not explicitly set. The new default value will be an empty string and notnull
as it was previously.Comments/Suggestions
Fieldmanager_Textarea
class to address this deprecation issue.Acceptance Criteria
null
return value,esc_textarea
will now receive an empty string instead ofnull
.