Bug 35792 - Quiet warning: Use of uninitialized value $sub6
Summary: Quiet warning: Use of uninitialized value $sub6
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching - Elasticsearch (show other bugs)
Version: Main
Hardware: All All
: P5 - low trivial
Assignee: Yvonne Waterman
QA Contact: Marcel de Rooy
URL:
Keywords: Academy, additional_work_needed
Depends on:
Blocks:
 
Reported: 2024-01-12 14:26 UTC by Magnus Enger
Modified: 2024-08-05 13:28 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This removes a warning message[1] that appears in the reindexing output when using Elasticsearch. The warning was generated if there was no value in 880$6 (880 = Alternate Graphic Representation, $6 = Linkage), but there were other 880 subfields with a value, for example 880$a. [1] Use of uninitialized value $sub6 in pattern match (m//) at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 619.
Version(s) released in:
24.11.00
Circulation function:


Attachments
Bug 35792: Use of uninitialized value $sub6 (1.11 KB, patch)
2024-07-25 22:51 UTC, Koha Training Catalyst
Details | Diff | Splinter Review
Bug 35792: Use of uninitialized value $sub6 (1.27 KB, patch)
2024-07-25 23:05 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 35792: Use of uninitialized value $sub6 (1.32 KB, patch)
2024-07-29 01:20 UTC, David Nind
Details | Diff | Splinter Review
Bug 35792: Use of uninitialized value $sub6 (1.42 KB, patch)
2024-08-02 07:37 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Magnus Enger 2024-01-12 14:26:14 UTC
When reindexing Elasticsearch, this warning can sometimes be seen: 

Use of uninitialized value $sub6 in pattern match (m//) at /usr/share/koha/lib/Koha/SearchEngine/Elasticsearch.pm line 601.

This warning is from 23.05.06. In master it looks like the relevant line is now line 603. I think it could be silenced by changing the line from this: 

if ($sub6 =~ /^(...)-\d+/) {

to this: 

if ($sub6 && $sub6 =~ /^(...)-\d+/) {
Comment 1 Koha Training Catalyst 2024-07-25 22:51:01 UTC
Created attachment 169619 [details] [review]
Bug 35792: Use of uninitialized value $sub6

Test plan:

1. Rerun and make sure the error "Use of uninitialized value $sub6 in pattern match (m//) at /usr/share/koha/lib/Koha/SearchEngine/Elastricsearch.pm" is no longer present.
Comment 2 Chris Cormack 2024-07-25 23:05:42 UTC
Created attachment 169622 [details] [review]
Bug 35792: Use of uninitialized value $sub6

Test plan:

1. Apply patch
2. Rerun and make sure the error "Use of uninitialized value $sub6 in pattern match (m//) at /usr/share/koha/lib/Koha/SearchEngine/Elastricsearch.pm" is no longer present.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Initial testing done, it works well, needs an additional sign off from an external party
Comment 3 David Nind 2024-07-29 00:24:04 UTC
I tried to replicate the issue, but didn't see it in the output from reindexing (koha-elasticsearch --rebuild -d -b -a kohadev).

Does this require a record with an incorrect value in 880$6 (880 = Alternate Graphic Representation, $6 = Linkage) for this warning to appear?

I'm not familiar enough with this field, or what is checked for, to add an incorrect (or correct) value. (Sometime/most of the time, some MARC21 tags and subfields are a bit obtuse for me to understand - https://www.loc.gov/marc/bibliographic/bd880.html 8-).)
Comment 4 David Cook 2024-07-29 01:08:35 UTC
(In reply to David Nind from comment #3)
> Does this require a record with an incorrect value in 880$6 (880 = Alternate
> Graphic Representation, $6 = Linkage) for this warning to appear?

It looks like a record with a 880 but no $6.
Comment 5 David Nind 2024-07-29 01:18:47 UTC
(In reply to David Cook from comment #4)
> (In reply to David Nind from comment #3)
> > Does this require a record with an incorrect value in 880$6 (880 = Alternate
> > Graphic Representation, $6 = Linkage) for this warning to appear?
> 
> It looks like a record with a 880 but no $6.

Thanks David! That works - I can now replicate the issue!
Comment 6 David Nind 2024-07-29 01:20:16 UTC
Created attachment 169804 [details] [review]
Bug 35792: Use of uninitialized value $sub6

Test plan:

1. Apply patch
2. Rerun and make sure the error "Use of uninitialized value $sub6 in pattern match (m//) at /usr/share/koha/lib/Koha/SearchEngine/Elastricsearch.pm" is no longer present.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Initial testing done, it works well, needs an additional sign off from an external party

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 David Nind 2024-07-29 01:35:46 UTC
Testing notes (using koha-testing-docker (KTD)):

1. Start up KTD with Elasticsearch (7 or 8): ktd --es7 up
2. Edit the book framework so that 880$a and $880$6 are visible in the staff interface (Administration > MARC bibliographic frameworks > BKS > MARC structure).
3. Edit any record that uses the BKS framework and add a value for the 880$a sunfield.
4. Reindex: koha-elasticsearch --rebuild -d -b -a kohadev
5. As part of the output from reindexing this warning is generated:
   Use of uninitialized value $sub6 in pattern match (m//) at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch.pm line 619.
6. Apply the patch.
7. Restart everything: restart_all
8. Reindex: koha-elasticsearch --rebuild -d -b -a kohadev
9. No warning in the output!
Comment 8 Marcel de Rooy 2024-08-02 07:37:46 UTC
Created attachment 169988 [details] [review]
Bug 35792: Use of uninitialized value $sub6

Test plan:

1. Apply patch
2. Rerun and make sure the error "Use of uninitialized value $sub6 in pattern match (m//) at /usr/share/koha/lib/Koha/SearchEngine/Elastricsearch.pm" is no longer present.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

Initial testing done, it works well, needs an additional sign off from an external party

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 9 Katrin Fischer 2024-08-02 17:01:13 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 10 Katrin Fischer 2024-08-02 17:02:47 UTC
Welcome Yvonne, you are no officially a Koha developer :)
Comment 11 Katrin Fischer 2024-08-05 13:28:16 UTC
Hm, I just realized we missed that the email address in the patch was not personalized. We need to check what we can do for the contributors file. If it's only this one we can map Yvonne, but it's a bit dangerous for future contributions using this email address.