Bug 12860

Summary: Tools > Data export : "Don't export fields" option doesn't work
Product: Koha Reporter: Francois Charbonnier <francois.charbonnier>
Component: ToolsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P3 CC: chris, jonathan.druart, mtj, robin, tomascohen
Version: Main   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13040
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 10996    
Bug Blocks:    
Attachments: Bug 12860: the export tools explodes if a field is not exported
Bug 12860: the export tools explodes if a field is not exported
[PASSED QA] [PASSED QA] Bug 12860: the export tools explodes if a field is not exported

Description Francois Charbonnier 2014-09-02 19:05:53 UTC
I have just tested the data export tool on master.

The option "Don't export fields" doesn't work for a field tag (ie 650) but works for a subfield tag (ie 650a).
Comment 1 Robin Sheat 2014-10-23 01:00:33 UTC
on Bug 13040 Comment 3 I do a bit of diagnosis of this, copy pasting the relevant bits here:

Looking at the code, this can't work:

if ( $f =~ m/^(\d{3})(.)?$/ ) {
    my ( $field, $subfield ) = ( $1, $2 );

    # skip if this record doesn't have this field
    if ( defined $record->field($field) ) {
        if ( defined $subfield ) {
            my @tags = $record->field($field);
            foreach my $t (@tags) {
                $t->delete_subfields($subfield);
            }
        }
        else {
            $record->delete_fields($field);
        }
    }
}

where the 'delete_fields' line is the one causing the error. It can't take a tag like the regex pulls out, it must take a MARC::Field.
Comment 2 Jonathan Druart 2015-01-29 15:22:43 UTC Comment hidden (obsolete)
Comment 3 Robin Sheat 2015-01-29 22:04:58 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2015-01-30 08:08:09 UTC
(In reply to Robin Sheat from comment #3)
> Created attachment 35614 [details] [review] [review]

> Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
> 
> Export fails to asplode with this patch

Hum? What happen with this patch?
Comment 5 Robin Sheat 2015-01-30 10:08:59 UTC
(In reply to Jonathan Druart from comment #4)
> (In reply to Robin Sheat from comment #3)
> > Created attachment 35614 [details] [review] [review] [review]
> 
> > Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
> > 
> > Export fails to asplode with this patch
> 
> Hum? What happen with this patch?

Nothing, that's what I said :-)
Comment 6 Kyle M Hall 2015-01-30 12:39:21 UTC
Created attachment 35619 [details] [review]
[PASSED QA] [PASSED QA] Bug 12860: the export tools explodes if a field is not exported

To reproduce:
1/ Go on tools/export.pl
2/ Export some records and specify you don't want the fields 245 (the
whole field, do not specify a subfield).
3/ Export, BOOM
Software error:
Arguments must be MARC::Field object at /home/koha/src/tools/export.pl line 400.

Test plan:
Apply the patch and confirm the fields 245 are not exported and the
export works as expected.

Signed-off-by: Robin Sheat <robin@catalyst.net.nz>

Export fails to asplode with this patch

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

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 7 Tomás Cohen Arazi 2015-02-05 18:29:49 UTC
Patch pushed to master.

Thanks Jonathan!
Comment 8 Chris Cormack 2015-02-10 22:03:31 UTC
Pushed to 3.18.x will be in 3.18.4
Comment 9 Mason James 2015-02-26 03:34:27 UTC
(In reply to Chris Cormack from comment #8)
> Pushed to 3.18.x will be in 3.18.4

Pushed to 3.16.x, will be in 3.16.8