[Bug 29781] New: Allow item batch modification to use capturing groups in regex option
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Bug ID: 29781 Summary: Allow item batch modification to use capturing groups in regex option 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: andrew@bywatersolutions.com QA Contact: testopia@bugs.koha-community.org CC: m.de.rooy@rijksmuseum.nl Bug 23873 seeks to make capturing groups usable in batch record mod. We should do the same with items. -- 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=29781 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@ptfs-europe | |.com Assignee|koha-bugs@lists.koha-commun |martin.renvoize@ptfs-europe |ity.org |.com -- 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=29781 --- Comment #1 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 129526 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129526&action=edit Bug 29781: This patch adds a unit test for capture groups support in Koha::Items Test plan 1) Run the test prior to applying the capture groups fix, note it fails. 2) Apply the capture groups fix patch 3) Run the test again, it should now pass -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 --- Comment #2 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 129527 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129527&action=edit Bug 29781: Enable capture groups in batch item modification This patch adds support for regular expression capture groups in MarcModificationTemplates. We escape double quotes in the replacement string, then quote the whole string before applying the `ee` modifier to the final regex application. See https://blog.james.rcpt.to/2010/10/25/perl-search-and-replace-using-variable... for further details. Test plan 1) Attempt to use capture groups in your regular expression based batch item modification and note it does not work. 2) Apply the patch and try again, this time the capture group should yield the expected results. 3) Run t/SimpleMARC.t and confirm the tests still pass. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 --- Comment #3 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 129528 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129528&action=edit Bug 29781: Unit test This patch adds a unit test for capture groups support in Koha::Items Test plan 1) Run the test prior to applying the capture groups fix, note it fails. 2) Apply the capture groups fix patch 3) Run the test again, it should now pass -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129527|0 |1 is obsolete| | --- Comment #4 from Martin Renvoize <martin.renvoize@ptfs-europe.com> --- Created attachment 129529 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129529&action=edit Bug 29781: Enable capture groups in batch item modification This patch adds support for regular expression capture groups in MarcModificationTemplates. We escape double quotes in the replacement string, then quote the whole string before applying the `ee` modifier to the final regex application. See https://blog.james.rcpt.to/2010/10/25/perl-search-and-replace-using-variable... for further details. Test plan 1) Attempt to use capture groups in your regular expression based batch item modification and note it does not work. 2) Apply the patch and try again, this time the capture group should yield the expected results. 3) Run t/SimpleMARC.t and confirm the tests still pass. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129526|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=29781 --- Comment #5 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- A quick hypothetical example using this to find call numbers that don't have volume and copy numbers in the correct order. To test: 1: have 2 items with these call numbers: - KF 123 .A987 c. 11 v. 22 - KF 123 .A987 v. 3 c. 1 2: put those items in item batch mod 3: do a regex substitution on call number: - s/(^[A-Z]+ \d+\b)\s+(\.[A-Z]+\d+\b)\s+(c\.\s\d+\b)\s+(v\.\s\d+\b)/$1 $2 $4 $3/ 4: Observe your call numbers are now: - KF 123 .A987 v. 22 c.11 - KF 123 .A987 v. 3 c. 1 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Andrew Fuerste-Henry <andrew@bywatersolutions.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=29781 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129528|0 |1 is obsolete| | --- Comment #6 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 129573 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129573&action=edit Bug 29781: Unit test This patch adds a unit test for capture groups support in Koha::Items Test plan 1) Run the test prior to applying the capture groups fix, note it fails. 2) Apply the capture groups fix patch 3) Run the test again, it should now pass Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129529|0 |1 is obsolete| | --- Comment #7 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 129574 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=129574&action=edit Bug 29781: Enable capture groups in batch item modification This patch adds support for regular expression capture groups in MarcModificationTemplates. We escape double quotes in the replacement string, then quote the whole string before applying the `ee` modifier to the final regex application. See https://blog.james.rcpt.to/2010/10/25/perl-search-and-replace-using-variable... for further details. Test plan 1) Attempt to use capture groups in your regular expression based batch item modification and note it does not work. 2) Apply the patch and try again, this time the capture group should yield the expected results. 3) Run t/SimpleMARC.t and confirm the tests still pass. Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 AspenCat Team <aspencatteam@clicweb.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aspencatteam@clicweb.org -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 --- Comment #8 from AspenCat Team <aspencatteam@clicweb.org> --- Signing off. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129573|0 |1 is obsolete| | --- Comment #9 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 130498 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=130498&action=edit Bug 29781: Unit test This patch adds a unit test for capture groups support in Koha::Items Test plan 1) Run the test prior to applying the capture groups fix, note it fails. 2) Apply the capture groups fix patch 3) Run the test again, it should now pass Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Jo Hunter <jhunter@clicweb.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #129574|0 |1 is obsolete| | --- Comment #10 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 130499 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=130499&action=edit Bug 29781: Enable capture groups in batch item modification This patch adds support for regular expression capture groups in MarcModificationTemplates. We escape double quotes in the replacement string, then quote the whole string before applying the `ee` modifier to the final regex application. See https://blog.james.rcpt.to/2010/10/25/perl-search-and-replace-using-variable... for further details. Test plan 1) Attempt to use capture groups in your regular expression based batch item modification and note it does not work. 2) Apply the patch and try again, this time the capture group should yield the expected results. 3) Run t/SimpleMARC.t and confirm the tests still pass. Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Jo Hunter <jhunter@clicweb.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Nick Clemens <nick@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=29781 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #130498|0 |1 is obsolete| | --- Comment #11 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 130508 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=130508&action=edit Bug 29781: Unit test This patch adds a unit test for capture groups support in Koha::Items Test plan 1) Run the test prior to applying the capture groups fix, note it fails. 2) Apply the capture groups fix patch 3) Run the test again, it should now pass Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Jo Hunter <jhunter@clicweb.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #130499|0 |1 is obsolete| | --- Comment #12 from Nick Clemens <nick@bywatersolutions.com> --- Created attachment 130509 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=130509&action=edit Bug 29781: Enable capture groups in batch item modification This patch adds support for regular expression capture groups in MarcModificationTemplates. We escape double quotes in the replacement string, then quote the whole string before applying the `ee` modifier to the final regex application. See https://blog.james.rcpt.to/2010/10/25/perl-search-and-replace-using-variable... for further details. Test plan 1) Attempt to use capture groups in your regular expression based batch item modification and note it does not work. 2) Apply the patch and try again, this time the capture group should yield the expected results. 3) Run t/SimpleMARC.t and confirm the tests still pass. Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> Signed-off-by: Jo Hunter <jhunter@clicweb.org> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@bywatersolutions.com --- Comment #13 from Nick Clemens <nick@bywatersolutions.com> --- I tried executing code and couldn't exploit it perl -e 'use Koha::Items; warn Koha::Items::apply_regex({value=>q{KF 123 .A987 c. 11 v. 22},search=>q{(^[A-Z]+ \d+\b)\s+(\.[A-Z]+\d+\b)\s+(c\.\s\d+\b)\s+(v\.\s\d+\b)}, replace=>q{ $1 $2 $4 $3 object_class() }});' If I comment out the lines that quote the replace I get 'Koha::Items' - so that protection seems to work -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Nick Clemens <nick@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |nick@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=29781 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |release-notes-needed CC| |fridolin.somers@biblibre.co | |m -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 --- Comment #14 from Fridolin Somers <fridolin.somers@biblibre.com> --- Great :) Looking forward to see Bug 23873 in passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |Manual -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 --- Comment #15 from Fridolin Somers <fridolin.somers@biblibre.com> --- It will be important to document this. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Fridolin Somers <fridolin.somers@biblibre.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Passed QA |Pushed to master Version(s)| |22.05.00 released in| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 --- Comment #16 from Fridolin Somers <fridolin.somers@biblibre.com> --- Pushed to master for 22.05, thanks to everybody involved 🦄 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Kyle M Hall <kyle@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED CC| |kyle@bywatersolutions.com Status|Pushed to master |RESOLVED -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Martin Renvoize <martin.renvoize@ptfs-europe.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Text to go in the| |This enhancement adds release notes| |support for capture groups | |in the regular expression | |option of batch item | |modification. | | | |One may now | |use `(\d+)` for example to | |capture digits in the match | |and then the `$1` | |placeholder in the replace. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29781 Lisette Scheer <lisette@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|release-notes-needed | -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org