Bug 12616

Summary: Locale in subscriptions not preselecting correctly
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: SerialsAssignee: Bernardo Gonzalez Kriegel <bgkriegel>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: bgkriegel, chris, colin.campbell, jonathan.druart+koha, liz, tomascohen
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 12616: Locale in subscriptions not preselecting correctly
Bug 12616: Locale in subscriptions not preselecting correctly
Bug 12616: Locale in subscriptions not preselecting correctly

Description Katrin Fischer 2014-07-20 21:53:01 UTC
The locale field in subscriptions currently defaults to empty, with a note that in this case English will be used automatically.

If it really defaults to English, then it would make sense to offer an option to preselect it to the currently selected template language or to a language chosen in configuration.
Comment 1 Katrin Fischer 2014-07-20 21:53:32 UTC
Note: in our 3.16.1 installation it always defaults to "Urdu"... I was not able to reproduce this in master, but have seen it multiple times when testing and presenting.
Comment 2 Katrin Fischer 2015-04-02 08:53:56 UTC
This is still a problem in

The pull down defaults to Urdu instead of empty.

The note says:  If empty, English is used - independent of the selected display language.
Comment 3 Katrin Fischer 2015-04-02 08:59:23 UTC
Hm, there is a deeper problem behind this in the creation of the language list. Multiple entries are marked as selected in the source code with an empty value attribute:

 <option value="por">Português (Portuguese)</option>
 <option value="rum">Român (Romanian)</option>
 <option value="rus">Русский (Russian)</option>
 <option value="" selected="selected">Cрпски (Serbian)</option>
 <option value="spa">Español (Spanish)</option>
 <option value="swe">Svenska (Swedish)</option>
 <option value="" selected="selected">Tetun (Tetum)</option>
 <option value="tha">ภาษาไทย (Thai)</option>
 <option value="tur">Türkçe (Turkish)</option>
 <option value="ukr">Українська (Ukranian)</option>
 <option value="" selected="selected">اردو (Urdu)</option>

The preselection of Urdu also happens in the English GUI.
Comment 4 Katrin Fischer 2015-05-15 21:40:10 UTC
Somethins strange is happening here - on master the options are clean and complete, but on switching to German the language list stays in English?
Comment 5 Bernardo Gonzalez Kriegel 2015-05-15 23:04:23 UTC
Sorry but can't reproduce, on master and 3.16.10
Tried using German and Spanish
Comment 6 Katrin Fischer 2015-05-24 14:18:35 UTC
I think the problem might be missing language descriptions - some of our installations are pretty old. I will try to update the database tables and see if this fixes the problem.
Comment 7 Katrin Fischer 2015-06-17 14:19:13 UTC
Hm, bit puzzled here. I have 2 installations, both currently.

Example: Urdu

Installation 1:
<option value="" selected="selected">اردو (Urdu)</option>

Installation 2:
<option value="urd" selected="selected">اردو (Urdu)</option>

I haven't spotted the difference in the database yet, that would cause the difference. The one showing the code directly is actually the older database.

There are about 4-5 languages where the code is missing in the list. They are all also 'selected'.
Comment 8 Bernardo Gonzalez Kriegel 2015-06-17 15:29:01 UTC
To reproduce on master: delete a couple of values from language_rfc4646_to_iso639 table.

For example 
DELETE FROM language_rfc4646_to_iso639 WHERE rfc4646_subtag IN ('ta','ur')

gives a pulldown that defaults to Urdu (or the last lang without 3 letter code)
and 'ta' (tamil) is also selected.

Problem is missing values in that table.
We can hide the problem removing pulldown entries without proper iso639-2 code
Comment 9 Katrin Fischer 2015-06-17 15:56:40 UTC
That might be good - I think I can fix this database with your hints, but there are probably more installations out there with that problem. It looks like we don't have a clean state for installations that have gone threw a few updates.
Comment 10 Bernardo Gonzalez Kriegel 2015-06-17 16:32:52 UTC Comment hidden (obsolete)
Comment 11 Katrin Fischer 2015-06-17 17:38:10 UTC
You're the best - thx Bernardo!
Comment 12 Mark Tompsett 2015-06-18 00:49:13 UTC Comment hidden (obsolete)
Comment 13 Jonathan Druart 2015-06-18 08:02:37 UTC
Don't you think it's better to fix the DB data?
Comment 14 Katrin Fischer 2015-06-18 08:10:00 UTC
I think we should do both - it could be hard to get all edge cases for the old databases where we have slacked with the database updates. 

This fixes a problem until we can figure out a more complete solution (maybe bug 12017?)
Comment 15 Jonathan Druart 2015-06-18 08:12:35 UTC
Created attachment 40254 [details] [review]
Bug 12616: Locale in subscriptions not preselecting correctly

There is a problem if a language is present but
don't have ISO639-2 code. Locale pulldown on serial
suscription is malformed.

To reproduce on master:
a) remove some entries on language_rfc4646_to_iso639
b) go to Serials > New suscription
c) Put any value on Vendor and record, press Next>>
d) Look at locale pulldown, it must default to last
removed lang from a), also other langs has no value
and are also 'selected' on html

To test:
1) Reproduce the problem
2) Apply the patch
3) Add New suscription, pulldown must be fixed

NOTE: Deleted Urdu and Chinese.
      Master had both "selected" in the HTML.
      Applied patch, neither were added.
      Defaults to first item, which is blank meaning English.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
Comment 16 Tomás Cohen Arazi 2015-06-22 14:56:54 UTC
Patch pushed to master.

Good catch Bernardo!
Comment 17 Chris Cormack 2015-07-09 21:18:49 UTC
Pushed to 3.20.x will be in 3.20.2
Comment 18 Liz Rea 2015-07-20 22:11:54 UTC
Pushed to 3.18.x will be in 3.18.09