Created
April 29, 2024 15:06
-
-
Save junaidpv/898cb6f6e1fc0a3c02153bd04b212bef 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 583c34e..b160b07 100644 | |
--- a/src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php | |
+++ b/src/Plugin/Field/FieldFormatter/ComputedStringFormatter.php | |
@@ -60,10 +60,10 @@ 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