Problem/Motivation
When \Drupal\filter\Entity\FilterFormat::$name is NULL deprecations are triggered on PHP 8.1
Steps to reproduce
Run \Drupal\Tests\comment\Kernel\CommentActionsTest
Proposed resolution
Set the default to an empty string? Given we're doing a trim on save() it's probably okay. The other solution is to ensure filter formats always have a label when created in a test.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3240247-6.patch | 4.26 KB | alexpott |
| #6 | 2-6-interdiff.txt | 4.49 KB | alexpott |
| #2 | 3240247-2.patch | 498 bytes | alexpott |
Comments
Comment #2
alexpottComment #3
andypostI find that's enough, moreover there's todo in the property docs to rename it to label so default anyway should be empty string - for PHP 7.4 it could become
protected ?string $label;Comment #4
alexpottI'm not sure - if this is just tests then I think we should do what we did for roles and fix the tests and leave the whole can a label for entities ever be NULL to the follow-up.
Comment #5
daffie commentedTo me, the change feels wrong. Almost everywhere in core have entity properties a default value of null. Why do it here now? What is the alternative change to fix this problem for PHP 8.1?
Comment #6
alexpott@daffie regardless of your feeling since FilterFormat::preSave() does:
the affect of that is that the NULL return of a label() on a saved filter format is impossible.
That said we should explore #4 and see where we're saving a filter format without a label.
Here's a patch that fixes all that I can find and adds an assert.
Comment #7
daffie commentedI like this change much more.
Looks good to me.
Comment #8
catchCommitted 3fc999a and pushed to 9.3.x. Thanks!
Comment #10
catch