Main Koha release repository https://koha-community.org
Find a file
Jonathan Druart 6d2e5f58f2 Bug 11413: Change the field number logic
This patch series is a bugfix for the Marc modification templates tool.

Bug description:
If you want to do an action (delete/update/move/...) on a multivalued
field and if a condition is defined on the same field, it is highly
probable the resulted record will not be what you expect.

For example:
Deleting All (or the first) fields 650 if 245$a="Bad title" works with
the current code.
BUT if you want to delete All (or the first) fields 650 with a condition
on 650$9=42, and if at least one field matches the condition :
- if you have selected all, all fields 650 will be deleted, even the
  ones who do not match the condition.
- if you have selected first, the first 650 field will be deleted, even
  if it does not match the condition.
The expected behavior is to delete the fields matching the
condition (and not all the 650 fields).

What this patch does:
This patch introduces 2 changes in the logic of Koha::SimpleMARC.
The first change is a change of the prototypes for the 2 routines
field_exists and field_equals. Now they return the "field number" of the
matching fields.
The second change is the type of the "n" parameter for all routines
using it in Koha::SimpleMARC. Before this patch, the "n" parameter was a
boolean in most cases. If 0, the action was done on all fields, if 1
on the first one only. Now it is possible to specify the "field numbers"
(so the array of field numbers which is returned by field_exists or
field_equals) for all routines which had the n parameter.

Test plan for the patch series:
Note: This test plan describes a specific example, feel free to create
your own one.
0/ Define a marc modification template with the following action:
  Delete field 245 if 245$9 = 42
1/ choose and export a record with several 245 fields.
For ex:
  245
    $a The art of computer programming
    $c Donald E. Knuth.
    $9 41
  245
    $a Bad title
    $c Bad author
    $9 42
2/ import it using the Stage MARC for import tool.
3/ verify the imported record does not contain any 245 field.
4/ apply all the patches from this bug report
5/ do again steps 2 and 3
6/ verify the imported record contains only one 245 field, the one with
245$9=41
7/ verify the unit tests passed:
  prove t/SimpleMARC.t
  prove t/db_dependent/MarcModificationTemplates.t

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2014-11-14 12:05:40 -03:00
acqui Bug 12979: Fix error on layout3pagesfr 2014-11-07 15:03:36 -03:00
admin Bug 9043: Syspref improvement: add new type "multiple" 2014-11-10 12:25:12 -03:00
authorities Bug 12573: Use correct comparison for comparing strings 2014-10-28 10:44:21 -03:00
basket Bug 9530 making changes to basket/sendbasket.pl 2014-10-27 10:38:20 -03:00
C4 Bug 11413: Change the field number logic 2014-11-14 12:05:40 -03:00
catalogue Bug 13225: Z39.50 result Card View doesn't work for UNIMARC 2014-11-10 11:59:48 -03:00
cataloguing Bug 13203: Plugin housekeeping: UNIMARC field 123i, 123j, 210c 2014-11-11 14:10:34 -03:00
circ Bug 12692 - Markup improvements to holds awaiting pickup report 2014-11-10 12:22:13 -03:00
course_reserves Bug 11349: Change .tmpl -> .tt in scripts using templates 2014-07-17 11:05:49 -03:00
debian Bug 11401: dependency updates 2014-11-14 10:08:08 -03:00
docs Bug 7143 Adding a new developer to the history 2014-10-11 16:23:08 -03:00
errors Bug 11349: Change .tmpl -> .tt in scripts using templates 2014-07-17 11:05:49 -03:00
etc Bug 13064 - Indexing problem with ICU on control characters 2014-11-14 12:03:12 -03:00
install_misc Bug 12068 - label-create-pdf.pl Add support for RTL language 2014-10-21 16:14:57 -03:00
installer Bug 11401: DBRev 3.17.00.055 2014-11-14 09:46:07 -03:00
Koha Bug 11413: Change the field number logic 2014-11-14 12:05:40 -03:00
koha-tmpl Bug 7988: Make note on authorized values page less confusing 2014-11-14 11:44:52 -03:00
labels Bug 11614: Untranslatable label_element_title in label management 2014-08-19 09:42:42 -03:00
members Bug 11401: QA followup 2014-11-14 09:42:45 -03:00
misc Bug 10136: Remove outdated translation tool docs 2014-11-14 11:41:45 -03:00
offline_circ Bug 11349: Change .tmpl -> .tt in scripts using templates 2014-07-17 11:05:49 -03:00
opac Bug 13116 [QA Followup] - Remove tabs, use unless instead of if 2014-11-12 11:23:45 -03:00
OpenILS Bug 9239 QA follow-up: remove stray debug code 2013-03-16 21:32:34 -04:00
patron_lists Bug 10565: (follow-up) add new user permission for patron list management 2013-10-14 22:43:03 +00:00
patroncards Bug 5502 - Patron card category search field should be menu 2014-08-10 09:30:47 -03:00
plugins Bug 11349: Change .tmpl -> .tt in scripts using templates 2014-07-17 11:05:49 -03:00
reports Bug 13141: Add ability for biblio_framework to be a dropdown in Guided Reports 2014-10-31 13:14:59 -03:00
reserve Bug 13116 [QA Followup] - Remove tabs, use unless instead of if 2014-11-12 11:23:45 -03:00
reviews Bug 11349: Change .tmpl -> .tt in scripts using templates 2014-07-17 11:05:49 -03:00
rotating_collections Bug 8836 [QA Followup] - Sort transfer branches alphabetically 2014-11-06 15:12:20 -03:00
selenium Adding selenium tests for filterMembers 2009-09-30 11:30:37 +02:00
serials Bug 5342: Serial claiming improvements: add a counter 2014-10-28 10:07:37 -03:00
services Bug 11349: Change .tmpl -> .tt in scripts using templates 2014-07-17 11:05:49 -03:00
skel Bug 11078: Add locking to rebuild_zebra 2014-02-28 22:21:41 +00:00
sms Bug 11349: Change .tmpl -> .tt in scripts using templates 2014-07-17 11:05:49 -03:00
suggestion Bug 12627: Fix default values 2014-11-07 15:17:10 -03:00
svc Bug 13232: Search patrons by a first letter should not redirect to a patron detail page 2014-11-14 09:33:00 -03:00
t Bug 11413: Change the field number logic 2014-11-14 12:05:40 -03:00
tags Bug 11349: Change .tmpl -> .tt in scripts using templates 2014-07-17 11:05:49 -03:00
test Bug 11349: Change .tmpl -> .tt in scripts using templates 2014-07-17 11:05:49 -03:00
tmp/modified_authorities
tools Bug 13082: fix to prevent adding of invalid records in marc file 2014-11-14 11:47:00 -03:00
virtualshelves Bug 9530 making changes to virtualshelves/sendshelf.pl 2014-10-27 10:38:25 -03:00
xt Bug 12653: (RM followup) Fix the test count 2014-10-29 20:43:52 -03:00
.editorconfig Bug 12545: Add EditorConfig.org file to the source tree 2014-08-22 11:07:45 -03:00
.htaccess Fix file permissions: if it is not a script, it should not be executable. 2010-04-16 00:40:34 -04:00
.mailmap Bug 12479: (QA followup) minor fixes, and tcohen added 2014-06-30 10:04:10 -03:00
about.pl Bug 13140: Add a notice on the About page about GRS-1 deprecated 2014-10-27 11:24:09 -03:00
changelanguage.pl Bug 6755 Problems with switching languages 2011-09-23 09:47:09 +12:00
edithelp.pl Bug 11661: sanitize file names supplied to edithelp.pl 2014-02-05 01:36:10 +00:00
fix-perl-path.PL installer: improvements to fix-path-perl.PL on Win32 2007-12-20 19:20:12 -06:00
help.pl Bug 11238: contruct links to the appropriate manual version dynamically 2013-11-23 19:30:16 +00:00
INSTALL Bug 7759, update of install files to use background indexing (and some whitespace tidy) 2012-04-20 16:11:52 +02:00
install-CPAN.pl Bug 5370: Fix all the references to koha.org 2010-11-08 09:41:49 +13:00
INSTALL.debian Bug 8092 follow-up: Add optional dependency on CHI 2012-06-09 13:08:18 +02:00
INSTALL.fedora7 Bug 11757: remove dependency on POE 2014-02-15 01:38:15 +00:00
INSTALL.opensuse Bug 11757: remove dependency on POE 2014-02-15 01:38:15 +00:00
INSTALL.ubuntu Bug 7764: (follow-up) editorial tweaks 2013-10-04 16:27:55 +00:00
koha_perl_deps.pl bug 10548: fix count of missing required dependencies by koha_perl_deps.pl 2013-07-11 14:03:32 +00:00
kohaversion.pl Bug 11401: DBRev 3.17.00.055 2014-11-14 09:46:07 -03:00
LICENSE Bug 9440 - update Koha's LICENSE file from GPL2 to GPL3 2013-02-12 08:52:10 -05:00
mainpage.pl Bug 11349: Change .tmpl -> .tt in scripts using templates 2014-07-17 11:05:49 -03:00
Makefile.PL Bug 12651: DOM indexing is the default 2014-10-27 12:35:44 -03:00
MANIFEST.SKIP Bug 9546 : Updating make manifest tardist 2013-02-06 23:54:46 -05:00
README Bug 9440 - update Koha's LICENSE file from GPL2 to GPL3 2013-02-12 08:52:10 -05:00
README.robots Bug 6411 add another example to README.robots 2011-07-05 14:48:05 +12:00
rewrite-config.PL Bug 12031: [QA Follow-up] Undefined routine and change to koha-conf.xml 2014-10-27 10:38:11 -03:00

Koha is a free software integrated library system.

Koha is distributed under the GNU GPL version 3 or later.
Please read the file LICENSE for more details.

To install or upgrade Koha, please see the INSTALL file appropriate
to your platform.

Report bugs at http://bugs.koha-community.org/

Visit the Koha Project website at http://www.koha-community.org/