Bugzilla – Attachment 22393 Details for
Bug 8015
Add MARC Modifications Templates
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8015: Followup: FIX cp and mv if subfields don't exist.
Bug-8015-Followup-FIX-cp-and-mv-if-subfields-dont-.patch (text/plain), 3.12 KB, created by
Kyle M Hall (khall)
on 2013-10-25 13:30:40 UTC
(
hide
)
Description:
Bug 8015: Followup: FIX cp and mv if subfields don't exist.
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-10-25 13:30:40 UTC
Size:
3.12 KB
patch
obsolete
>From 7ae487f6ad5acc3795c2cb1b6a2c12f70d8ea1f2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Mon, 13 Aug 2012 17:04:05 +0200 >Subject: [PATCH] Bug 8015: Followup: FIX cp and mv if subfields don't exist. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Leila <koha.aixmarseille@gmail.com> > >Bug 8015: Followup: On move, we cant delete existing fields > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Leila <koha.aixmarseille@gmail.com> >--- > Koha/SimpleMARC.pm | 21 +++++++++++++++------ > 1 files changed, 15 insertions(+), 6 deletions(-) > >diff --git a/Koha/SimpleMARC.pm b/Koha/SimpleMARC.pm >index 96a3af1..82abe00 100644 >--- a/Koha/SimpleMARC.pm >+++ b/Koha/SimpleMARC.pm >@@ -74,7 +74,7 @@ at your option, any later version of Perl 5 you may have available. > =cut > > sub copy_field { >- my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ) = @_; >+ my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n, $dont_erase ) = @_; > C4::Koha::Log( "C4::SimpleMARC::copy_field( '$record', '$fromFieldName', '$fromSubfieldName', '$toFieldName', '$toSubfieldName', '$regex', '$n' )" ) if $debug; > > if ( ! ( $record && $fromFieldName && $toFieldName ) ) { return; } >@@ -90,7 +90,7 @@ sub copy_field { > } > } > >- update_field( $record, $toFieldName, $toSubfieldName, @values ); >+ update_field( $record, $toFieldName, $toSubfieldName, @values, $dont_erase ); > > } > >@@ -109,7 +109,7 @@ sub copy_field { > =cut > > sub update_field { >- my ( $record, $fieldName, $subfieldName, @values ) = @_; >+ my ( $record, $fieldName, $subfieldName, @values, $dont_erase ) = @_; > C4::Koha::Log( "C4::SimpleMARC::update_field( $record, $fieldName, $subfieldName, @values )" ) if $debug; > > if ( ! ( $record && $fieldName ) ) { return; } >@@ -123,8 +123,17 @@ sub update_field { > my $field; > if ( $subfieldName ) { > if ( my @fields = $record->field( $fieldName ) ) { >- foreach my $field ( @fields ) { >- $field->update( "$subfieldName" => $values[$i++] ); >+ unless ( $dont_erase ) { >+ foreach my $field ( @fields ) { >+ $field->update( "$subfieldName" => $values[$i++] ); >+ } >+ } >+ if ( $i <= scalar @values - 1 ) { >+ foreach my $field ( @fields ) { >+ foreach my $j ( $i .. scalar( @values ) - 1) { >+ $field->add_subfields( "$subfieldName" => $values[$j] ); >+ } >+ } > } > } else { > ## Field does not exist, create it. >@@ -253,7 +262,7 @@ sub field_equals { > sub move_field { > my ( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ) = @_; > C4::Koha::Log( "C4::SimpleMARC::move_field( '$record', '$fromFieldName', '$fromSubfieldName', '$toFieldName', '$toSubfieldName', '$regex', '$n' )" ) if $debug; >- copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n ); >+ copy_field( $record, $fromFieldName, $fromSubfieldName, $toFieldName, $toSubfieldName, $regex, $n , "don't_erase"); > delete_field( $record, $fromFieldName, $fromSubfieldName, $n ); > } > >-- >1.7.2.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8015
:
9313
|
9329
|
9330
|
9331
|
10089
|
11579
|
11607
|
11608
|
12280
|
12288
|
12569
|
12570
|
12571
|
12572
|
12839
|
12856
|
12857
|
12858
|
12859
|
12860
|
13121
|
13138
|
13495
|
14030
|
14031
|
14032
|
14033
|
14034
|
14035
|
14040
|
16330
|
16331
|
16332
|
16333
|
16334
|
16335
|
16363
|
16376
|
16377
|
16378
|
16379
|
16413
|
16415
|
16423
|
16455
|
16468
|
16470
|
16471
|
16472
|
16473
|
16475
|
16476
|
16477
|
16478
|
16479
|
16480
|
17036
|
17037
|
17038
|
18372
|
18441
|
21024
|
21025
|
21026
|
21027
|
21028
|
21029
|
21030
|
21031
|
21032
|
21033
|
21034
|
21035
|
21036
|
21037
|
21038
|
21371
|
21484
|
21485
|
21486
|
21487
|
21808
|
21809
|
21876
|
21901
|
21902
|
21903
|
21904
|
21905
|
21906
|
21907
|
21908
|
21909
|
21910
|
21911
|
21912
|
21913
|
21914
|
21915
|
21916
|
21917
|
21918
|
21919
|
21920
|
22185
|
22186
|
22187
|
22188
|
22189
|
22190
|
22284
|
22285
|
22290
|
22293
|
22392
| 22393 |
22394
|
22395
|
22396
|
22397
|
22398
|
22399
|
22400
|
22401