Problem/Motivation
username has a character limit of 60. If we create a user with name of 58 or 59 characters and try to translate a content, translation will not get saved. However on creating or editing a content in original language, it gets saved.
In authoring information tab (in node add, edit), 'Authored by' has maxlength 1024. Only in translation form, Authored by inside translation tab has maxlength 60. In the same translation form, Authored by field inside 'Authoring information' tab has maxlength 1024 and this causes issue.
The ContentTranslationHandler adds an entity_autocomplete field with a maxlength of 60 characters to the node edit form. The intent is probably to match the value in use on the UserInterface::USERNAME_MAX_LENGTH. However the autocomplete selection adds the (nid) to the selected username. If the value is greater than the limit it prevents submit the node edit form.
Steps to reproduce
Set a entity type as translatable. Create a user with a very long username (ex: 59 characters).
Create an entity with this user and save it.
Create a translation and try to save it.
Proposed resolution
Remove the maxlength attribute on the field.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | before-after-comparison.jpg | 544.88 KB | igorgoncalves |
| #3 | node add form in original language.png | 139.66 KB | annmarysruthy |
Issue fork drupal-3473029
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
annmarysruthy commentedIn authoring information tab (in node add, edit), 'Authored by' has maxlength 1024. Only in translation form, Authored by inside translation tab has maxlength 60. In the same translation form, Authored by field inside 'Authoring information' tab has maxlength 1024 and this causes issue.
Instead of removing maxlength, I would recommend changing maxlength of 'Authored By' inside translation tab to 1024 and make it same as ' Authored by' field inside 'Authoring information' tab
Comment #4
annmarysruthy commentedComment #6
quietone commentedChanges are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.
Comment #9
annmarysruthy commentedComment #10
smustgrave commentedNew approach will need issue summary update.
Also might be nice to get a test showing how this is a probelm.
Comment #11
annmarysruthy commentedComment #13
dcam commentedI added a test. The IS was updated in #11.
Comment #14
igorgoncalves commentedThanks @dcam
I just followed the steps to reproduce and i confirm the error at the time to create my test content translation.
And after applying the patch, i could create the translation with no problem.
Drupal version 11.2.0-dev
Comment #15
smustgrave commentedPulled up the original issue #1807800: Add status and authoring information as generic entity translation metadata and don't see any discussion around using 60 so I imagine no one is super against changing.
Test-only job didn't run https://git.drupalcode.org/issue/drupal-3473029/-/jobs/5575179
Ran locally but it seems to be passing so may need some tweaking
Comment #17
dcam commentedI asked in the core-development Slack if the test-only job passes because the new assertions are in an abstract base class. Per @godotislate that is the case. The test-only runner looks for changes in *Test.php files. I was advised to create a test-only MR, which I did in MR 12393.
Comment #18
dcam commentedAnd now you can see that multiple content translation UI tests are failing. Thank you @godotislate!
Comment #19
smustgrave commentedGood to know, but the test failure happening doesn't appear to happen around the code being introduced.
Also
This could probably be updated.
Comment #20
dcam commentedI improved the test. I think it's probably good to go now.
Comment #22
smustgrave commentedHiding the test-only branch incase the bot picks it up.
But I see that the failures are now coming from the added test coverage
│ /builds/issue/drupal-3473029/core/modules/content_translation/tests/src/Functional/ContentTranslationUITestBase.php:368
That was the only feedback I had, so believe this one is good to go.
Comment #24
longwaveBackported to 11.2.x as an eligible bug fix. This could also go to 10.5.x/10.6.x but doesn't cherry-pick cleanly; if anyone feels strongly about that please reopen with a backport MR against 10.6.x.
Committed and pushed 970ce375723 to 11.x and 6d8c0395f8f to 11.2.x. Thanks!
Comment #27
longwaveComment #29
herved commentedPatch for 10.5.x if anyone else needs it