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.
reproduce
1. download a .po from L.D.O server WITHOUT rename, and place into ranslations folder
2. normally install and you will get errors.
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null
Notice: Undefined index: xxxxxxx in locale_add_language() (line 460 of /var/www/xxx/includes/locale.inc).
We should not allow user pass that step if we catch a wrong file name.
Comment | File | Size | Author |
---|---|---|---|
#16 | install-1007488-16.patch | 1.86 KB | plach |
#10 | install-1007488-10.patch | 4.69 KB | plach |
#10 | before.png | 33.05 KB | plach |
#10 | after.png | 41.1 KB | plach |
#6 | install-non-predefined.patch | 1.39 KB | Gábor Hojtsy |
Comments
Comment #1
droplet CreditAttribution: droplet commentedwon't add to select list if filename not match lang code.
(It's only get fix but not the best I think. A more better way is match filename's lang code pattern than force user rename to lang code name)
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commentedDo we really want to prevent people from installing Drupal in a language that isn't on our predefined list? That doesn't seem right to me. I'm moving this to the "language system" queue for now, to get some more opinions on that. (I do think it might be better if we did some validation of the file itself instead.)
The patch also has some code style issues; please see http://drupal.org/coding-standards. Thanks!
Comment #3
plachRelated issues:
#988262: Could not complete installation in French
#994500: Drupal should not require .po file rename in installation
Quoting a discussion between me and Gábor:
Comment #4
Gábor HojtsyI think the names are mixed up in the quoted discussion (actually, in the exact opposite :).
Also, I think the patch is going in a bad direction. We should not exclude languages which we don't have predefined from being installed with. We should make assumptions (set the name to the same as language code maybe?, set direction to LTR and set native name also to language code). I tried and reproduced this issue with a simple hk.po file in my standard profile translations BTW.
Providing a IMHO great patch at #994500: Drupal should not require .po file rename in installation for the long file name problem and retitling this to be more accurate.
Comment #5
podaroksubscribe
Comment #6
Gábor HojtsyOk, so here is my suggested patch. Modifying how locale_add_language() works would constitute an API change IMHO, so instead I added a predefined language check in the installer and prefilled "dummy" (AKA the best we know) values for the language. Also fixed empty string, boolean, etc type matches in the invocation. To reproduce and test the bugfix:
- put in an empty hk.po in profiles/standard/translations
- pick "hk" in installation
- without patch it should break with the reported error (see issue starter)
- with patch, it should continue, even run a batch to import the (empty) .po file and once installed, the language list will have an item for it:
Comment #7
Gábor HojtsyIssue summary
Drupal can be installed localized by putting .po files under install profile directories. The languages Drupal finds are offered for selection in the installer. Drupal has a list of predefined languages, but it also offers languages when a .po file was found but the language is unknown to Drupal. In this case, Drupal does not know about the full name, native name and direction of the language but it tries to add it as if those details were available. We need to fill in these details with some "dummy" information in this case to ensure adding a language fulfills the database constraints. This information can be edited later by administrators.
The impact of the bug is big because localize.drupal.org keeps adding new languages and when those are downloaded as .po files, those can be selected, but the installer fails with them and cannot complete.
Comment #8
meba CreditAttribution: meba commentedApplied the patch and tested install:
- With Czech language - worked
- With empty hk.po - worked
Comment #9
plachThe patch has code style issues and does not work with filenames longer than 12 chars. Working on it just now.
Comment #10
plachAnd here it is. Language code is truncated to 12 chars to fit into the {languages} table.
Comment #11
plachAdditional test case covered: rename a valid .po file downloaded from l.d.o with a name longer than 12 chars: strings should be regularly imported.
Comment #13
plachNo failure on my box.
#10: install-1007488-10.patch queued for re-testing.
Comment #14
Gábor HojtsyThat does not really work, since it will import regional variant translations as well. Think if you have pt.po pt-br.po, both will be imported with the new code if language code is pt, only first will be imported with the old code in the same situation (which is the right behavior). Same not just for language variants, but if a language code is prefix to another one (which is entirely possible since localize.drupal.org has some longer than 2 letter language codes due to no 2 letter code language keys assigned to certain languages). Eg. just added Tuvan with the language code "tyv", and there can very well be a language with the code "ty", although there is not one yet on localize.drupal.org.
I think we'd rather skip files with long language codes, they are not valid anyway. Just don't offer those on the UI. We already fixed the localize.drupal.org file download issue, so long language codes should really be very-very-very rare.
Comment #15
plach@Gábor Hojtsy:
Ok, this works for me.
Comment #16
plachImplemented #14.
Comment #17
droplet CreditAttribution: droplet commentedWith predefined lang code - worked
With non-predefined lang code - worked
With empty hk.po - worked
With 20 long name - not pass (expected, so worked)
Comment #18
webchickHm. This really seems like it could still benefit from Gábor's final review.
Comment #19
Gábor HojtsyLooks all good on a visual review as well.
Comment #20
webchickExcellent, thanks.
Committed to HEAD!