Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
\Drupal\config_translation\FormElement\Textarea
can cause deprecations on PHP 8.1 because it passes NULL to a string function.
Steps to reproduce
Run \Drupal\Tests\node\Functional\NodeTypeTranslationTest on PHP 8.1
Proposed resolution
Fix code to not pass NULL to a string function.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#7 | 3240174-7.patch | 1.15 KB | alexpott |
#7 | 2-7-interdiff.txt | 825 bytes | alexpott |
#2 | 3240174-2.patch | 1.15 KB | alexpott |
Comments
Comment #2
alexpottHere's the fix from the meta.
Comment #3
andypostWithout patch
with patch test pass
not clear why second log has more failures of
strtolower()
Comment #4
alexpott@andypost because it gets further in the test. The point of listing the test is not say the test will be green after this change on PHP 8.1 the point it to say what triggers the deprecation so we can investigate whether this is the best fix and why at this point $translation_config is NULL.
Comment #5
daffie CreditAttribution: daffie commentedTo me this is not the right check. The PHP functions
str_word_count()
andsubstr_count()
both want the first parameter to be a string value. See: https://www.php.net/manual/en/function.str-word-count.php and https://www.php.net/manual/en/function.substr-count.php.Comment #6
alexpott#5 is pretty moot. We map config that has the type 'text' to '\Drupal\config_translation\FormElement\Textarea' - so $translation_config can only be NULL or
not seta string.I guess there is a question about whether or not we should cast the value to something that complies with the config schema - however then we'd have to deal with nullables so back to the same issue.
Another question that comes to mind is should we use the source config if the translation config is NULL as a guide to the number of rows.
[Edit: correctness]
Comment #7
alexpottComment #8
andypostI see no reason in it
Comment #9
daffie CreditAttribution: daffie commentedAs the variable $rows_newlines has a minimum value of 1, the variable $rows also has a minimum value of 1. Changing the default value of the variable $rows to 1 is to me the right solution.
It looks good to me.
Comment #11
catchCommitted 2145374 and pushed to 9.3.x. Thanks!