Bug 41713 - warnings sometimes generated when using ShowComponentRecords feature
Summary: warnings sometimes generated when using ShowComponentRecords feature
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low normal
Assignee: Janusz Kaczmarek
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-01-26 14:38 UTC by Janusz Kaczmarek
Modified: 2026-01-27 20:36 UTC (History)
2 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: Sponsored
Comma delimited list of Sponsors: Ignatianum University in Cracow
Crowdfunding goal: 0
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 41713: warnings sometimes generated when using ShowComponentRecords feature (4.16 KB, patch)
2026-01-26 18:15 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 41713: Unit tests (1.35 KB, patch)
2026-01-26 18:15 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 41713: warnings sometimes generated when using ShowComponentRecords feature (4.23 KB, patch)
2026-01-26 18:19 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 41713: Unit tests (1.35 KB, patch)
2026-01-26 18:19 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 41713: warnings sometimes generated when using ShowComponentRecords feature (4.28 KB, patch)
2026-01-27 20:36 UTC, Roman Dolny
Details | Diff | Splinter Review
Bug 41713: Unit tests (1.40 KB, patch)
2026-01-27 20:36 UTC, Roman Dolny
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Janusz Kaczmarek 2026-01-26 14:38:43 UTC
When using ShowComponentRecords feature warnings like:

[WARN] Use of uninitialized value in concatenation (.) or string at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm line 352.
[WARN] Use of uninitialized value $comp_query_str in concatenation (.) or string at /kohadevbox/koha/catalogue/detail.pl line 273.

are generated from staff interface detail view when:
1. ShowComponentRecords = 'both' or 'staff' AND
2. UseControlNumber is on AND
3. record lacks 001 field

Similarly, from OPAC interface:

[WARN] Use of uninitialized value in concatenation (.) or string at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm line 352.
[WARN] Use of uninitialized value $comp_query_str in concatenation (.) or string at /kohadevbox/koha/opac/opac-detail.pl line 640.
Comment 1 Janusz Kaczmarek 2026-01-26 18:15:05 UTC
Created attachment 192054 [details] [review]
Bug 41713: warnings sometimes generated when using ShowComponentRecords feature

When using ShowComponentRecords feature warnings are generated from
staff interface detail view when:
1. ShowComponentRecords = 'both' or 'staff' AND
2. UseControlNumber is on AND
3. record lacks 001 field

Test plan
=========
1. Have a standard ktd instance with Elasticsearch.
2. Set UseControlNumber systempreference to Use.
3. In OPAC and in staff interface, open in Normal
   view a record without field 001, e.g. # 399
   ("Art Since 1980").
4. Check plack-opac-error.log and plack-intranet-error.log.
   You should see fresh warnings like:
   [WARN] Use of uninitialized value in concatenation (.) or string at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm line 352.
   [WARN] Use of uninitialized value $comp_query_str in concatenation (.) or string at /kohadevbox/koha/opac/opac-detail.pl line 640

   [WARN] Use of uninitialized value in concatenation (.) or string at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm line 352.
   [WARN] Use of uninitialized value $comp_query_str in concatenation (.) or string at /kohadevbox/koha/catalogue/detail.pl line 273.
5. Apply the patch; restart_all.
6. Repeat p. 4. There should be no new warnings.

Sponsored-by: Ignatianum University in Cracow
Comment 2 Janusz Kaczmarek 2026-01-26 18:15:07 UTC
Created attachment 192055 [details] [review]
Bug 41713: Unit tests
Comment 3 Janusz Kaczmarek 2026-01-26 18:19:39 UTC
Created attachment 192056 [details] [review]
Bug 41713: warnings sometimes generated when using ShowComponentRecords feature

When using ShowComponentRecords feature warnings are generated from
staff interface detail view when:
1. ShowComponentRecords = 'both' or 'staff' AND
2. UseControlNumber is on AND
3. record lacks 001 field

Test plan
=========
1. Have a standard ktd instance with Elasticsearch.
2. Set UseControlNumber systempreference to Use.
   Set ShowComponentRecords systempreference to both staff and OPAC.
3. In OPAC and in staff interface, open in Normal
   view a record without field 001, e.g. # 399
   ("Art Since 1980").
4. Check plack-opac-error.log and plack-intranet-error.log.
   You should see fresh warnings like:
   [WARN] Use of uninitialized value in concatenation (.) or string at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm line 352.
   [WARN] Use of uninitialized value $comp_query_str in concatenation (.) or string at /kohadevbox/koha/opac/opac-detail.pl line 640

   [WARN] Use of uninitialized value in concatenation (.) or string at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm line 352.
   [WARN] Use of uninitialized value $comp_query_str in concatenation (.) or string at /kohadevbox/koha/catalogue/detail.pl line 273.
5. Apply the patch; restart_all.
6. Repeat p. 4. There should be no new warnings.

Sponsored-by: Ignatianum University in Cracow
Comment 4 Janusz Kaczmarek 2026-01-26 18:19:41 UTC
Created attachment 192057 [details] [review]
Bug 41713: Unit tests
Comment 5 Janusz Kaczmarek 2026-01-26 18:24:24 UTC
Nota bene: the key change is to examine the @{$components} array, not the reference to the array ($components) in 'if' statement. 

In the old version:

if ( my $components = $biblio->get_marc_components(...

the condition is always true since get_marc_components always returns an array reference, even if if is an empty array.
Comment 6 Roman Dolny 2026-01-27 20:36:22 UTC
Created attachment 192106 [details] [review]
Bug 41713: warnings sometimes generated when using ShowComponentRecords feature

When using ShowComponentRecords feature warnings are generated from
staff interface detail view when:
1. ShowComponentRecords = 'both' or 'staff' AND
2. UseControlNumber is on AND
3. record lacks 001 field

Test plan
=========
1. Have a standard ktd instance with Elasticsearch.
2. Set UseControlNumber systempreference to Use.
   Set ShowComponentRecords systempreference to both staff and OPAC.
3. In OPAC and in staff interface, open in Normal
   view a record without field 001, e.g. # 399
   ("Art Since 1980").
4. Check plack-opac-error.log and plack-intranet-error.log.
   You should see fresh warnings like:
   [WARN] Use of uninitialized value in concatenation (.) or string at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm line 352.
   [WARN] Use of uninitialized value $comp_query_str in concatenation (.) or string at /kohadevbox/koha/opac/opac-detail.pl line 640

   [WARN] Use of uninitialized value in concatenation (.) or string at /kohadevbox/koha/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm line 352.
   [WARN] Use of uninitialized value $comp_query_str in concatenation (.) or string at /kohadevbox/koha/catalogue/detail.pl line 273.
5. Apply the patch; restart_all.
6. Repeat p. 4. There should be no new warnings.

Sponsored-by: Ignatianum University in Cracow
Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 7 Roman Dolny 2026-01-27 20:36:25 UTC
Created attachment 192107 [details] [review]
Bug 41713: Unit tests

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>