Notice: Undefined index: name in locale_languages_edit_form_validate()
When you attempt to create a custom language, if you put markup in the name or native name, you are supposed to get a validation error, but instead you get a PHP notice AND broken validation error message. The validation checks if the name contains any markup, but unfortunately the form_error call uses an undefined variable.

It should look like this:

| Comment | File | Size | Author |
|---|---|---|---|
| #29 | custom_language_validation-1295048-29-FAIL.patch | 2.08 KB | kbasarab |
| #29 | custom_language_validation-1295048-29.patch | 1.25 KB | kbasarab |
| #29 | interdiff.txt | 858 bytes | kbasarab |
| #27 | custom_language_validation-1295048-27.patch | 1.25 KB | kbasarab |
| #27 | interdiff.txt | 790 bytes | kbasarab |
Comments
Comment #1
loganfsmyth commentedHere's a fix. I'll come back and make a test for the error in a bit.
Comment #2
loganfsmyth commentedHere's a different fix that should be better. The issue is that the validation function is used in two places with slightly different form structure. This passes the proper sub-form to the validation function.
I've attached my failing test and the fix patch.
Comment #4
loganfsmyth commentedThat was supposed to fail.
Comment #5
xjm#2 looks good to me. Thanks for your work on this patch. Note that the Drupal 8.x patch will need to be rerolled, because the core directory structure for Drupal 8 has now changed. (For more information, see #22336: Move all core Drupal files under a /core folder to improve usability and upgrades). When the patch has been rerolled, please set the issue back to "Needs Review."
Tagging as novice for the task of rerolling the Drupal 8.x patch.
If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.
Comment #6
kathyh commentedUpdated for #5 - D8 /core
Comment #8
xjmHere's the failed tests:
Comment #9
loganfsmyth commentedAs of #1301148: Stop pretending we have configuration translation for languages, native language name has been removed. I've updated the patches to match.
Comment #11
loganfsmyth commentedWorked.
Comment #13
loganfsmyth commentedOkay, lets try this again...
Comment #14
xjm#13: Sorry about that; the test-only patch had the "wrong" fail so I retested it. It's fixed now in either case. :)
Comment #15
xjm#9: locale-notice-custom-language-1295048-9.patch queued for re-testing.
Comment #16
swentel commentedSo, the code for adding language simply moved to another file. Reuploading patches, first one will fail (due to a notice because wrong form is passed), second one should pass.
Comment #18
swentel commentedMeh, moving the test to the bottom of all tests so it doesn't interfere with the flow there is now.
Comment #19
lazysoundsystem commentedThe patches from #18 no longer applied. Here they are again.
Comment #20
xjm#19: custom_language_validation-1295048-19.patch queued for re-testing.
Comment #21
xjmThe patch didn't apply anymore, but let's reroll it (and also remove the
t()from the assertion message). Looks RTBC to me once that's taken care of.Comment #23
kbasarab commentedRerolls and removes assertion message t().
Comment #24
lars toomre commentedLooks like t('The English language has been removed.') was missed in #23. There should be no t() around this assert message.
Comment #25
kbasarab commentedOops, good catch Lars. Fixed....
Comment #26
lars toomre commentedI just noticed that the t() in the drupalPost call was removed in #23. That should be put back. Only t() around assert messages should be removed. Sorry for not noticing it the first time.
Comment #27
kbasarab commentedComment #28
yesct commentedThe patch in #27 looks like a re-roll of the fail patch in #19. I dont see the "fix"
So I think the patch custom_language_validation-1295048-27.patch needs to be renamed custom_language_validation-1295048-XX-fail.patch to indicate this is the patch without the fix, but with the test that is supposed to detect the problem, and that it's expected the testbot will show it fails.
And another patch needs to be added with the fix and the test and that can be named normally, that is the one that should pass. See #2 for an example, of one patch that fails (the one with just the test) and one that passes (the patch with the fix and the test).
Posting interdiffs is a bit tricky, I'd just post an interdiff between the normal patch (with the fix and the test) and the patch in #19. Then maybe post a diff between the regular patch and the fail patch (that will show just what the fix was).
Even after that is done though, I'm worried. It seems like the fail patch is going to pass. So that means either that the fix is not the fix, or the test is not testing what it should... But lets worry about that after seeing the fail and the normal patch first.
Comment #29
kbasarab commentedOk so I think I see what happened here. Looks like the "fix' YesCT mentioned is missing is actually already in core. So this leads us back to strictly testing.
Attached I have the same patch as #27. Reverting the fix that was made at some point in core (not sure how to use Git blame to see when that happened) and attach that patch as a -FAIL and then the interdiff showing what I changed to create the fail.
We'll see if these fail/pass test bot as expected.
Comment #30
kbasarab commentedOk so I found the issue where this was committed to 8.x:
#1751082: Undefined index: langcode in language_admin_edit_form_validate
Looks like this task is a duplicate of that.
Comment #32
xjm@kbasarab, so the task is just to add the test coverage then? Or are there existing tests in core that also duplicate what's being added here? (If the latter, we can close this issue as a duplicate.)
Comment #33
kbasarab commentedxjm: Test coverage was added in #1751082: Undefined index: langcode in language_admin_edit_form_validate also so I believe this is a full duplicate of that case.
Test for this specific case from #21 in http://drupal.org/node/1751082#comment-6423144
Marking as duplicate. Feel free to reopen though if you see something I'm missing.