Bug 27738

Summary: Set fallback for unset DefaultCountryField008 to |||, "no attempt to code"
Product: Koha Reporter: Phil Ringnalda <phil>
Component: CatalogingAssignee: Phil Ringnalda <phil>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: andrewfh, fridolin.somers, jonathan.druart, julian.maurice, m.de.rooy, martin.renvoize, victor
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00,20.11.05,20.05.11
Bug Depends on: 13912    
Bug Blocks: 27739    
Attachments: Bug 27738: Set fallback for unset DefaultCountryField008 to |||, "no attempt to code"
Bug 27738: Set fallback for unset DefaultCountryField008 to |||, "no attempt to code"
Bug 27738: Set fallback for unset DefaultCountryField008 to |||, "no attempt to code"
Bug 27738: Fix wording

Description Phil Ringnalda 2021-02-21 17:06:43 UTC
Bug 13912 added DefaultCountryField008 to allow defaulting the place of publication to something other than the previous default of xxu ("somewhere in the  United States, but I don't know what state"). Trying to follow the Koha Way of never changing existing behavior, only adding a preference to fix it, it intended to fall back to xxu, but https://git.koha-community.org/gitweb/?p=koha.git;a=blob;f=cataloguing/value_builder/marc21_field_008.pl;h=b3c5d0c47f908edaa376b397a3bae5ecf8013c9e;hb=HEAD#l80 thought the preference would be undefined if it wasn't set, and then a QA followup updated the DB to add it so it's always defined, and the // "xxu" is unreached and the default value of the pref, '', gets space-padded to three characters long, '   '.

Since we've now gone 3.3 years with the default having switched from the unfortunate choice of 'xxu' to the invalid '   ' without anyone filing a bug about it, I assert that the Koha Way is wrong in this case, that nobody actually wanted to retain the behavior of defaulting to saying that every book was published in an unknown US state (or if they did exist, they already fixed it by using that as their DefaultCountryField008), and we can fix the bug of defaulting to an invalid value by choosing a new default when DefaultCountryField008 isn't set, the value "|||" which is "no attempt to code" which is precisely the case when the cataloger doesn't change it and the system adminstrator doesn't say it should have a particular value whether or not that value is correct.
Comment 1 Phil Ringnalda 2021-02-21 18:56:08 UTC
Created attachment 117126 [details] [review]
Bug 27738: Set fallback for unset DefaultCountryField008 to |||, "no attempt to code"

Current code intended to set a fallback of xxu, an unknown state in the US,
but because the preference is always defined, just sometimes unset, it
actually falls back to three spaces, an invalid value. This patch instead
uses the fallback value ||| which means no attempt to code.

Test plan:
1. Without the patch, verify that the value of the system preference
DefaultCountryField008 is empty.
2. Cataloging - New record - Default framework (if you have the Advanced
editor enabled, Settings - Switch to basic editor, this only applies to the
basic editor)
3. On tab 0, click in the text input for field 008 which fills in default
values, then click the Tag editor button at the end of the field
4. In the popup window, verify that the value for 15-17 is shown as ###
indicating three spaces
5. Apply patch, repeat the steps above, verify that the value is now |||
Comment 2 Phil Ringnalda 2021-02-21 19:01:07 UTC
Bah, forgot the last two steps,

6. Set DefaultCountryField008 to abc
7. Repeat steps 2-3 and verify that the value for 15-17 is abc
Comment 3 Martin Renvoize 2021-02-22 09:01:52 UTC
Created attachment 117134 [details] [review]
Bug 27738: Set fallback for unset DefaultCountryField008 to |||, "no attempt to code"

Current code intended to set a fallback of xxu, an unknown state in the US,
but because the preference is always defined, just sometimes unset, it
actually falls back to three spaces, an invalid value. This patch instead
uses the fallback value ||| which means no attempt to code.

Test plan:
1. Without the patch, verify that the value of the system preference
DefaultCountryField008 is empty.
2. Cataloging - New record - Default framework (if you have the Advanced
editor enabled, Settings - Switch to basic editor, this only applies to the
basic editor)
3. On tab 0, click in the text input for field 008 which fills in default
values, then click the Tag editor button at the end of the field
4. In the popup window, verify that the value for 15-17 is shown as ###
indicating three spaces
5. Apply patch, repeat the steps above, verify that the value is now |||

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2021-02-22 09:03:55 UTC
Works as expected and provides a more sane default.  Signing off.
Comment 5 Julian Maurice 2021-03-31 11:43:33 UTC
Created attachment 119041 [details] [review]
Bug 27738: Set fallback for unset DefaultCountryField008 to |||, "no attempt to code"

Current code intended to set a fallback of xxu, an unknown state in the US,
but because the preference is always defined, just sometimes unset, it
actually falls back to three spaces, an invalid value. This patch instead
uses the fallback value ||| which means no attempt to code.

Test plan:
1. Without the patch, verify that the value of the system preference
DefaultCountryField008 is empty.
2. Cataloging - New record - Default framework (if you have the Advanced
editor enabled, Settings - Switch to basic editor, this only applies to the
basic editor)
3. On tab 0, click in the text input for field 008 which fills in default
values, then click the Tag editor button at the end of the field
4. In the popup window, verify that the value for 15-17 is shown as ###
indicating three spaces
5. Apply patch, repeat the steps above, verify that the value is now |||

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Julian Maurice <julian.maurice@biblibre.com>
Comment 6 Jonathan Druart 2021-04-01 16:28:07 UTC
+            - " Empty defaults to ||| for No attempt to code."

Is the uppercase expected ("No")?
Comment 7 Phil Ringnalda 2021-04-01 17:31:05 UTC
Fun question!

To me, it's clearly a quote of the formal description of the fill character from the spec, where no is always capitalized. However, when I went looking for an example in the spec, I realized that the spec editors very carefully duck the question: they'll use the actual term from descriptions when it is at the start of a sentence, but otherwise they'll use other phrases like "when no attempt has been made to code." The single example of using the actual term I found in the 008 spec was 

15-17 - Place of publication, production, or execution

Two- or three-character alphabetic code that indicates the place of publication, production, or execution.

which argues that I'm wrong. Perhaps " Empty defaults to ||| - No attempt to code." (which is a copy-paste from the spec, including the dash) would be more correct, but I'd be just as happy with a lowercase no.
Comment 8 Jonathan Druart 2021-04-06 12:39:49 UTC
Created attachment 119211 [details] [review]
Bug 27738: Fix wording
Comment 9 Jonathan Druart 2021-04-06 13:57:45 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 10 Fridolin Somers 2021-04-15 10:55:14 UTC
Pushed to 20.11.x for 20.11.05
Comment 11 Andrew Fuerste-Henry 2021-04-25 13:12:24 UTC
Pushed to 20.05.x for 20.05.11
Comment 12 Victor Grousset/tuxayo 2021-04-25 17:10:41 UTC
Not backported to oldoldstable (19.11.x). Feel free to ask if it's needed.