Problem/Motivation
In the past, it was possible to create path_file entities with an empty Name. These entities were saved in the database with a null value for the "name" column. With Drupal 11 and strict type checking, a null name (which is the entity label) now breaks Entity->toLink() with the following error on the admin/structure/path_file_entity page:
TypeError: Drupal\Component\Utility\Html::escape(): Argument #1 ($text) must be of type string, null given, called in /var/www/html/docroot/core/lib/Drupal/Core/Utility/LinkGenerator.php on line 199 in Drupal\Component\Utility\Html::escape() (line 433 of core/lib/Drupal/Component/Utility/Html.php).
Steps to reproduce
Reproducing is a little tricky because you need an existing path_file entity with name = null, which was possible in earlier versions of Drupal. However, if you have one or more such path_file entities, when you go to /admin/structure/path_file_entity, you'll see the above error.
You can reproduce a related error by attempting to add a path_file entity with an empty name.
- Go to /admin/structure/path_file_entity/add
- Leave the Name field empty, but populate the other fields
- Save and Publish it
- Observe the error
Proposed resolution
- Provide a database update that sets all null names to something like "[unnamed]".
- Make Name required on the /admin/structure/path_file_entity/add form and on the edit form.
Remaining tasks
See above.
User interface changes
With the above changes, "Name" will now be a required field for all path_file entities. This aligns with other entities where the label is required.
API changes
n/a
Data model changes
"Name" will now be required, consistent with other entity labels.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | path_file_3614703.patch | 28.16 KB | paulmckibben |
Issue fork path_file-3614703
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
paulmckibbenComment #4
paulmckibbenHere's a patch against the 2.1.0 release that contains the latest changes from the 2.0.x branch as well as the code from the MR.
Comment #5
batigolixI could reproduce the error. I tested your solution and it works fine. Thanks
Comment #6
batigolix