[Bug 36515] New: Amend MARC modification templates so control fields can be copied to subfields
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Bug ID: 36515 Summary: Amend MARC modification templates so control fields can be copied to subfields Change sponsored?: --- Product: Koha Version: master Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Cataloging Assignee: koha-bugs@lists.koha-community.org Reporter: alexbuckley@catalyst.net.nz QA Contact: testopia@bugs.koha-community.org CC: m.de.rooy@rijksmuseum.nl It would be nice if MARC modification templates could work with control fields - specifically to copy control fields to subfields. A MARC control field is a field where the tag is less than 10, e.g. 001. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Alex Buckley <alexbuckley@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|koha-bugs@lists.koha-commun |alexbuckley@catalyst.net.nz |ity.org | -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Alex Buckley <alexbuckley@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Change sponsored?|--- |Sponsored -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #1 from Alex Buckley <alexbuckley@catalyst.net.nz> --- Created attachment 164575 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=164575&action=edit Bug 36515: Amend MARC modification templates so control fields can be copied to subfields Test plan: 1. Apply patch and restart services 2. Create a MARC modification template to move 001 to 099$a 3. Perform a Batch record modification using your MARC modification template from #1 4. Confirm that the template has successfully moved the 001 control field value to the 099$a subfield Sponsored-by: Education Services Australia SCIS -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Alex Buckley <alexbuckley@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #164575|0 |1 is obsolete| | --- Comment #2 from Alex Buckley <alexbuckley@catalyst.net.nz> --- Created attachment 165924 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=165924&action=edit Bug 36515: Amend MARC modification templates so control fields can be copied to subfields Test plan: 1. Apply patch and restart services 2. Create a MARC modification template with the action: Copy and replace field 001 to 099$a unless 099$a exists 3. Perform a Batch record modification using your MARC modification template from #2 4. Confirm that the template has successfully moved the 001 control field value to the 099$a subfield Sponsored-by: Education Services Australia SCIS -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Alex Buckley <alexbuckley@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #165924|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #3 from Alex Buckley <alexbuckley@catalyst.net.nz> --- Created attachment 165928 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=165928&action=edit Bug 36515: Amend MARC modification templates so control fields can be copied to subfields Test plan: 1. Apply patch and restart services 2. Create a MARC modification template with the action: Copy and replace field 001 to 099$a unless 099$a exists 3. Perform a Batch record modification using your MARC modification template from #2 4. Confirm that the template has successfully moved the 001 control field value to the 099$a subfield Sponsored-by: Education Services Australia SCIS -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #4 from Alex Buckley <alexbuckley@catalyst.net.nz> --- Created attachment 165929 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=165929&action=edit Bug 36515: Add unit tests Test plan: 1. Run unit tests ktd --shell prove t/SimpleMARC.t Sponsored-by: Education Services Australia SCIS -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Alex Buckley <alexbuckley@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |Needs Signoff --- Comment #5 from Alex Buckley <alexbuckley@catalyst.net.nz> --- Ready for testing. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #165928|0 |1 is obsolete| | --- Comment #6 from David Nind <david@davidnind.com> --- Created attachment 166026 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=166026&action=edit Bug 36515: Amend MARC modification templates so control fields can be copied to subfields Test plan: 1. Apply patch and restart services 2. Create a MARC modification template with the action: Copy and replace field 001 to 099$a unless 099$a exists 3. Perform a Batch record modification using your MARC modification template from #2 4. Confirm that the template has successfully moved the 001 control field value to the 099$a subfield Sponsored-by: Education Services Australia SCIS Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #165929|0 |1 is obsolete| | --- Comment #7 from David Nind <david@davidnind.com> --- Created attachment 166027 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=166027&action=edit Bug 36515: Add unit tests Test plan: 1. Run unit tests ktd --shell prove t/SimpleMARC.t Sponsored-by: Education Services Australia SCIS Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #8 from Alex Buckley <alexbuckley@catalyst.net.nz> --- Thanks for testing David! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #166026|0 |1 is obsolete| | Attachment #166027|0 |1 is obsolete| | --- Comment #9 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 169215 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=169215&action=edit Bug 36515: Add unit tests Test plan: 1. Run unit tests ktd --shell prove t/SimpleMARC.t Sponsored-by: Education Services Australia SCIS Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #10 from Kyle M Hall <kyle@bywatersolutions.com> --- Created attachment 169216 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=169216&action=edit Bug 36515: (QA follow-up) Tidy code Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com QA Contact|testopia@bugs.koha-communit |kyle@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #11 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- It looks like something happened here and one of the patches was obsoleted. Trying to fix. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #166026|1 |0 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |release-notes-needed -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |24.11.00 released in| | Status|Passed QA |Pushed to main -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #12 from Katrin Fischer <katrin.fischer@bsz-bw.de> --- Pushed for 24.11! Well done everyone, thank you! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Lucas Gass <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Pushed to main |Needs documenting CC| |lucas@bywatersolutions.com --- Comment #13 from Lucas Gass <lucas@bywatersolutions.com> --- Enhancement will not be included in 24.05.x -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Katrin Fischer <katrin.fischer@bsz-bw.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|release-notes-needed | Text to go in the| |With this enhancement it's release notes| |now possible to copy the | |content of MARC control | |fields to MARC subfields. | |Example: copy 001 to 035$a. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Michał <schodkowy.omegi-0r@icloud.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schodkowy.omegi-0r@icloud.c | |om --- Comment #14 from Michał <schodkowy.omegi-0r@icloud.com> --- Something seems to be wrong with the logic there, I can enter to copy from 035a to 010 (without entering the `a`) subfield, and it doesn't trigger the alert in JS. if ( ( $("#to_field").val() >= 10 && $("#to_subfield").val().length > 0 ) && ( $("#from_field").val() >= 10 && $("#from_subfield").val().length > 0 ) ) { alert( __("Both subfield values should be filled or empty.") ); I believe the checks for `.length > 0` are erroneous here. It doesn't actually check anything, it could only trigger if subfield length was like 1 and 2, but it's impossible, since the HTML already validates it must be of length 1 max. The only possible lengths are 0 or 1, so logically it's impossible for both to be >0 (both be 1) while L1!=L2 in the check above. So that's a regression. Furthermore, in Koha/SimpleMARC.pm, while the logic in function `copy_field` was changed, the corresponding analogous one in `move_field` was not, so now the behavior is inconsistent. It also seems that trying to copy/move subfield to control field (the other way around) is broken. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #15 from Alex Buckley <alexbuckley@catalyst.net.nz> --- (In reply to Michał from comment #14)
Something seems to be wrong with the logic there, I can enter to copy from 035a to 010 (without entering the `a`) subfield, and it doesn't trigger the alert in JS.
if ( ( $("#to_field").val() >= 10 && $("#to_subfield").val().length > 0 ) && ( $("#from_field").val() >= 10 && $("#from_subfield").val().length > 0 ) ) { alert( __("Both subfield values should be filled or empty.") );
I believe the checks for `.length > 0` are erroneous here. It doesn't actually check anything, it could only trigger if subfield length was like 1 and 2, but it's impossible, since the HTML already validates it must be of length 1 max. The only possible lengths are 0 or 1, so logically it's impossible for both to be >0 (both be 1) while L1!=L2 in the check above. So that's a regression.
Furthermore, in Koha/SimpleMARC.pm, while the logic in function `copy_field` was changed, the corresponding analogous one in `move_field` was not, so now the behavior is inconsistent.
It also seems that trying to copy/move subfield to control field (the other way around) is broken.
Hi Michal, Taking a look at this. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #16 from Michał <schodkowy.omegi-0r@icloud.com> --- Thanks for quick response. Atm I can't wrap my head around why the other way around copying/moving doesn't work. Btw related bugs are: 22436, 27978 (they're both duplicates of each other that request copying between control/non-control both ways around). Btw I mislooked, it seems the func `copy_and_replace_field` was adjusted, while `copy_field` and `move_field` were not. As for JS side, I would propose such fix: ```js if ( ( $("#to_field").val() < 10 && $("#to_subfield").val().length > 0 ) || ( $("#from_field").val() < 10 && $("#from_subfield").val().length > 0 ) ) { alert( __("Control fields cannot have subfields.") ); return false; } else if ( $("#from_subfield").val().length != $("#to_subfield").val().length ) { alert( __("Both subfield values should be filled or empty.") ); return false; } ``` -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Michał <schodkowy.omegi-0r@icloud.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=22436 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Michał <schodkowy.omegi-0r@icloud.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=27978 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #17 from Michał <schodkowy.omegi-0r@icloud.com> --- And then I presume unit tests should have 6 variants total: two ways around x copy/move/copy_and_replace -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #18 from Michał <schodkowy.omegi-0r@icloud.com> --- [sorry for mail spam in advance] By reading the code, it appears that the reason the other way around doesn't work is that extracting the old value works both from subfield and control field, but the function that sets new value - _update_subfield - doesn't seem to handle setting control field value. The code path that we use (but regrettably both would have to be fixed) calls this: my $field = MARC::Field->new( $fieldName, '', '', "$subfieldName" => $values[$i++] ); To fix this, it should probably check if $subfieldName is `( !defined $subfieldName or $subfieldName eq '' )` and then if the $fieldName is `< "010"`, in such case it should instead run: MARC::Field->new( $fieldName, $values[$i++] ) In fact, this is almost exactly what func `add_field` in the same file does: if ( $fieldName > 10 ) { foreach my $value ( @values ) { my $field = MARC::Field->new( $fieldName, '', '', "$subfieldName" => $value ); $record->insert_fields_ordered( $field ); } } else { foreach my $value ( @values ) { my $field = MARC::Field->new( $fieldName, $value ); $record->insert_fields_ordered( $field ); } Turns out `_update_subfield` has a sister `_update_field`, which is why they don't do such a check. So `_copy_move_subfield` has to be changed from: _update_subfield({ record => $record, field => $toFieldName, subfield => $toSubfieldName, values => \@values, dont_erase => $dont_erase }); to have a check that calls `_update_field` instead if it's control. Unfortunately I don't have ktd setup handy next to me right now, so I can't file a fix for the time being. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #19 from Alex Buckley <alexbuckley@catalyst.net.nz> --- Hi Michal, Thanks very much for your notes, that makes sense. I think it would be best to create a new separate bug report that depends on this one for follow-up patches. Would you like to do that Michal? I won't have availability to write any follow-ups until mid next-week at the earliest, so please do feel free to go ahead if you would like. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Mathieu Saby <mathsabypro@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mathsabypro@gmail.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #20 from Mathieu Saby <mathsabypro@gmail.com> --- Hello, We are interested in this new feature. Is there still work to be done before it can be used? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Michelle Spinney <mspinney@clamsnet.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mspinney@clamsnet.org -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #21 from Mathieu Saby <mathsabypro@gmail.com> --- Could you please clarify if the issue raised in comment 18 have been reported as a separate bug? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 --- Comment #22 from Michał <schodkowy.omegi-0r@icloud.com> --- (In reply to Mathieu Saby from comment #21)
Could you please clarify if the issue raised in comment 18 have been reported as a separate bug?
Unfortunately I didn't follow up after my comments (lack of time and active motivation), so most likely a follow-up bug and fix were never created. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36515 Sara Brown <sbrown@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=42950 -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org