Bug 40128 - StripWhitespaceChars can create empty subfields
Summary: StripWhitespaceChars can create empty subfields
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: 2025-06-12 08:43 UTC by Janusz Kaczmarek
Modified: 2025-06-15 12:20 UTC (History)
3 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40128: StripWhitespaceChars can create empty subfields (2.28 KB, patch)
2025-06-14 22:15 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 40128: Unit tests (1.56 KB, patch)
2025-06-14 22:15 UTC, Janusz Kaczmarek
Details | Diff | Splinter Review
Bug 40128: StripWhitespaceChars can create empty subfields (2.33 KB, patch)
2025-06-15 12:19 UTC, Roman Dolny
Details | Diff | Splinter Review
Bug 40128: Unit tests (1.61 KB, patch)
2025-06-15 12:19 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 2025-06-12 08:43:49 UTC
When StripWhitespaceChars is enabled and the user by chance enters some white spaces in the input field, Koha generates empty subfield (or even entirely empty field).

To reproduce:
1. Enable StripWhitespaceChars system preference.
2. Edit an existing record, putting just some spaces into an empty subfield. Save the record.
3. Go to bibliographic record Normal view and in modal "MARC preview" notice that the subfield you entered spaces in exists as an empty subfield. If it was the only subfield in a field, the field exists with no data at all. This is wrong.

Koha::Filter::MARC::TrimFields::filter should be corrected to avoid this.
Comment 1 Janusz Kaczmarek 2025-06-14 22:15:11 UTC
Created attachment 183259 [details] [review]
Bug 40128: StripWhitespaceChars can create empty subfields

When StripWhitespaceChars is enabled and the user by chance enters
some white spaces in the input field, Koha generates empty subfield
(or even entirely empty field).

Test plan:
==========
1. Enable StripWhitespaceChars system preference.
2. Edit an existing record, putting just some spaces into an empty
   subfield. Save the record.
3. Go to bibliographic record Normal view and in modal "MARC preview"
   notice that the subfield you entered spaces in exists as an empty
   subfield. If it was the only subfield in a field, the field exists
   with no data at all. This is wrong.
4. Apply the patch ; restart_all.
5. Repeat 2. and 3. You should not see any empty subfield now. If the
   empty subbfield was the only subfield in a field, the field should
   have been removed from the record.
Comment 2 Janusz Kaczmarek 2025-06-14 22:15:13 UTC
Created attachment 183260 [details] [review]
Bug 40128: Unit tests
Comment 3 Roman Dolny 2025-06-15 12:19:26 UTC
Created attachment 183261 [details] [review]
Bug 40128: StripWhitespaceChars can create empty subfields

When StripWhitespaceChars is enabled and the user by chance enters
some white spaces in the input field, Koha generates empty subfield
(or even entirely empty field).

Test plan:
==========
1. Enable StripWhitespaceChars system preference.
2. Edit an existing record, putting just some spaces into an empty
   subfield. Save the record.
3. Go to bibliographic record Normal view and in modal "MARC preview"
   notice that the subfield you entered spaces in exists as an empty
   subfield. If it was the only subfield in a field, the field exists
   with no data at all. This is wrong.
4. Apply the patch ; restart_all.
5. Repeat 2. and 3. You should not see any empty subfield now. If the
   empty subbfield was the only subfield in a field, the field should
   have been removed from the record.

Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl>
Comment 4 Roman Dolny 2025-06-15 12:19:28 UTC
Created attachment 183262 [details] [review]
Bug 40128: Unit tests

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