From 2145374d1e183f3775ee027643dd014e16bb5951 Mon Sep 17 00:00:00 2001 From: catch Date: Mon, 4 Oct 2021 15:59:45 +0100 Subject: [PATCH] Issue #3240174 by alexpott, andypost, daffie: \Drupal\config_translation\FormElement\Textarea() can cause deprecations on PHP 8.1 --- .../config_translation/src/FormElement/Textarea.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/modules/config_translation/src/FormElement/Textarea.php b/core/modules/config_translation/src/FormElement/Textarea.php index 4308969e2dc..fdc7ea45399 100644 --- a/core/modules/config_translation/src/FormElement/Textarea.php +++ b/core/modules/config_translation/src/FormElement/Textarea.php @@ -14,13 +14,15 @@ class Textarea extends FormElementBase { */ public function getTranslationElement(LanguageInterface $translation_language, $source_config, $translation_config) { // Estimate a comfortable size of the input textarea. - $rows_words = ceil(str_word_count($translation_config) / 5); - $rows_newlines = substr_count($translation_config, "\n") + 1; - $rows = max($rows_words, $rows_newlines); + if (is_string($translation_config)) { + $rows_words = ceil(str_word_count($translation_config) / 5); + $rows_newlines = substr_count($translation_config, "\n") + 1; + $rows = max($rows_words, $rows_newlines); + } return [ '#type' => 'textarea', - '#rows' => $rows, + '#rows' => $rows ?? 1, ] + parent::getTranslationElement($translation_language, $source_config, $translation_config); }