Created
February 21, 2023 05:40
-
-
Save junaidpv/4a8348846864b18d91bc40761afad37e to your computer and use it in GitHub Desktop.
To fix this warning message originated from the computed_field module: Deprecated function: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in Drupal\Component\Utility\Html::escape() (line 424 of core/lib/Drupal/Component/Utility/Html.php).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php b/src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php | |
| index 36be5e9..697c3ba 100644 | |
| --- a/src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php | |
| +++ b/src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php | |
| @@ -57,9 +57,9 @@ class ComputedStringFormatter extends ComputedFormatterBase { | |
| protected function prepareValue($value) { | |
| if ($this->getSetting('sanitized')) { | |
| - return nl2br(Html::escape($value)); | |
| + return !empty($value) ? nl2br(Html::escape($value)) : $value; | |
| } else { | |
| - return nl2br($value); | |
| + return !empty($value) ? nl2br($value) : $value; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment