Bug 36163 - Can't select a country for usage statistics
Summary: Can't select a country for usage statistics
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Janusz Kaczmarek
QA Contact: Jonathan Druart
URL:
Keywords:
: 39013 (view as bug list)
Depends on:
Blocks:
 
Reported: 2024-02-24 21:57 UTC by Georg
Modified: 2025-02-17 14:22 UTC (History)
4 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 36163: Usage statistics - Not possible to select a country (1.95 KB, patch)
2025-01-20 14:40 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 36163: Usage statistics - Not possible to select a country (2.00 KB, patch)
2025-01-20 16:48 UTC, Roman Dolny
Details | Diff | Splinter Review
Bug 36163: Usage statistics - Not possible to select a country (2.44 KB, patch)
2025-01-23 12:05 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 36163: Usage statistics - Not possible to select a country (2.44 KB, patch)
2025-01-23 12:18 UTC, Roman Dolny
Details | Diff | Splinter Review
Bug 36163: Chomp country list (16.08 KB, patch)
2025-01-23 13:30 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Georg 2024-02-24 21:57:48 UTC
Site: .../cgi-bin/koha/admin/usage_statistics.pl

If you try to select a country, you get an error:
==
The value of your system preference 'UsageStatsCountry' is not valid (Germany). Please select a valid one.
==

It doesn't matter which country you chose, no country is valid.
Comment 1 Katrin Fischer 2024-03-17 16:36:01 UTC
Confirmed. There is also an error message:

Note: The value of your system preference 'UsageStatsCountry' is not valid (Algeria). Please select a valid one. 

The pull down appears to be the same as for  UsageStatsCountry system preference. Not sure what the right fix here would be.
Comment 2 Janusz Kaczmarek 2025-01-20 14:40:58 UTC
Created attachment 176822 [details] [review]
Bug 36163: Usage statistics - Not possible to select a country

Site: .../cgi-bin/koha/admin/usage_statistics.pl

If you try to select a country, you get an error:
==
The value of your system preference 'UsageStatsCountry' is not valid (Germany). Please select a valid one.
==

It doesn't matter which country you chose, no country is valid.

Test plan:
==========
1. Select a country for UsageStatsCountry system preference.
2. Go to http://<your addr>:8081/cgi-bin/koha/admin/usage_statistics.pl
3. Confirm the issue.
4. Apply the patch ; restart_all.
5. Repeat p. 2.
6. Confirm that the issue has been solved.

Sponsored-by: Ignatianum University in Cracow
Comment 3 Roman Dolny 2025-01-20 16:48:20 UTC
Created attachment 176831 [details] [review]
Bug 36163: Usage statistics - Not possible to select a country

Site: .../cgi-bin/koha/admin/usage_statistics.pl

If you try to select a country, you get an error:
==
The value of your system preference 'UsageStatsCountry' is not valid (Germany). Please select a valid one.
==

It doesn't matter which country you chose, no country is valid.

Test plan:
==========
1. Select a country for UsageStatsCountry system preference.
2. Go to http://<your addr>:8081/cgi-bin/koha/admin/usage_statistics.pl
3. Confirm the issue.
4. Apply the patch ; restart_all.
5. Repeat p. 2.
6. Confirm that the issue has been solved.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 4 Jonathan Druart 2025-01-23 10:47:22 UTC
Then I think should remove the trim later:

<option value="[% country.trim | html %]" selected="selected">[% country.trim | html %]</option>

IMO the best solution would be to trim at the beginning of the loop, but I guess yours also works.
Comment 5 Janusz Kaczmarek 2025-01-23 12:05:10 UTC
Created attachment 176954 [details] [review]
Bug 36163: Usage statistics - Not possible to select a country

Site: .../cgi-bin/koha/admin/usage_statistics.pl

If you try to select a country, you get an error:
==
The value of your system preference 'UsageStatsCountry' is not valid (Germany). Please select a valid one.
==

It doesn't matter which country you chose, no country is valid.

Test plan:
==========
1. Select a country for UsageStatsCountry system preference.
2. Go to http://<your addr>:8081/cgi-bin/koha/admin/usage_statistics.pl
3. Confirm the issue.
4. Apply the patch ; restart_all.
5. Repeat p. 2.
6. Confirm that the issue has been solved.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 6 Janusz Kaczmarek 2025-01-23 12:07:40 UTC
(In reply to Jonathan Druart from comment #4)
> Then I think should remove the trim later:
> 
> <option value="[% country.trim | html %]" selected="selected">[%
> country.trim | html %]</option>
> 
> IMO the best solution would be to trim at the beginning of the loop, but I
> guess yours also works.

Updated. Thanks, Jonathan. The mine didn't work for Zimbabwe (last from the list) anyway - there must have been a space added that obviously was not removed by split.
Comment 7 Roman Dolny 2025-01-23 12:18:15 UTC
Created attachment 176955 [details] [review]
Bug 36163: Usage statistics - Not possible to select a country

Site: .../cgi-bin/koha/admin/usage_statistics.pl

If you try to select a country, you get an error:
==
The value of your system preference 'UsageStatsCountry' is not valid (Germany). Please select a valid one.
==

It doesn't matter which country you chose, no country is valid.

Test plan:
==========
1. Select a country for UsageStatsCountry system preference.
2. Go to http://<your addr>:8081/cgi-bin/koha/admin/usage_statistics.pl
3. Confirm the issue.
4. Apply the patch ; restart_all.
5. Repeat p. 2.
6. Confirm that the issue has been solved.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 8 Jonathan Druart 2025-01-23 13:30:32 UTC
Created attachment 176956 [details] [review]
Bug 36163: Chomp country list

I found the same code in preferences.tt, actually we don't need to trim
if the list is properly generated (ie. without extra spaces)
Comment 9 Jonathan Druart 2025-01-23 13:31:38 UTC
Janusz, I think this is actually the correct fix, what do you think?

Ideally country-list.inc could return an array but I think it will be problematic to have a TT directive on several lines (it breaks the translation script).
Comment 10 Janusz Kaczmarek 2025-01-23 13:46:28 UTC
(In reply to Jonathan Druart from comment #9)
> Janusz, I think this is actually the correct fix, what do you think?

Sure, it's simpler and cleaner with ~ . 

The main point is that the issue is identified and resolved :)  Thanks, Jonathan, for having a deeper look into it.
Comment 11 Katrin Fischer 2025-01-24 10:55:24 UTC
Really glad to see this fixed after such a long time!
Comment 12 Katrin Fischer 2025-01-24 11:03:25 UTC
Pushed for 25.05!

Well done everyone, thank you!
Comment 13 Roman Dolny 2025-02-01 18:35:08 UTC
*** Bug 39013 has been marked as a duplicate of this bug. ***