marc export exports all records when using an empty list of record IDs
Bug #1329872 reported by
Robert Soulliere
This bug affects 3 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Evergreen |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
EG version 2.6
OpenSRF Version: 2.3
PostgreSQL Version: 9.1
Linux Distribution: Debian Squeeze
If trying to export records using the marc records export tool, all records will be exported if the file of IDs is empty.
For example:
In this case:
cat bibs.ids | /openils/
Records.marc will be all the records in the system if bibs.ids does not contain any record IDs.
tags: | added: cat-importexport |
Changed in evergreen: | |
status: | New → Confirmed |
To post a comment you must log in.
I can confirm that this can be a problem and is still a problem in 3.3 - 3.11.
If I setup a process to generate a list of bibs the differ from the last export to feed into the script, but I don't check to make sure that the list isn't empty then I'll accidentally send an --all dump.
It seems like --all and --pipe are just to validate other arguments, they are not used to see if ids haven't been passed.
The code that looks like it checks for ids, doesn't validate that zero IDs haven't been passed. Or that ctrl+d hasn't just been pressed.
# Look for passed in ids: >need_ids( )) {
my @ids = ();
if ($config-
print STDERR "Waiting for input\n" if (-t);
while (my $i = <>) {
push @ids, $i if ($i =~ /^\s*[0-9]+\s*$/);
}
}
There needs to be second check after that, to error out if no IDs were passed. Like.
die "IDs required but not entered, exiting\n" if ($config- >need_ids( ) && !@ids);
Before that change, these commands give the same result.
echo bob | marc_export
and
marc_export --all
and
echo bob | marc_export --pipe
After
$ echo bob | marc_export
IDs required but not entered, exiting
$ echo bob | marc_export --pipe
IDs required but not entered, exiting
Josh