| Summary: | GetNormalizedISBN only ever checks the first populated ISBN field | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Kyle M Hall (khall) <kyle> |
| Component: | Architecture, internals, and plumbing | Assignee: | Tomás Cohen Arazi (tcohen) <tomascohen> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P5 - low | CC: | barton, d.gavio, egpetridis, jonathan.druart, mathsabypro, tomascohen |
| Version: | Main | ||
| Hardware: | All | ||
| OS: | All | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | Patch complexity: | --- |
| Documentation contact: | Documentation submission: | ||
| Text to go in the release notes: | Version(s) released in: | ||
| Circulation function: | |||
| Attachments: | MARCXML file with multiple ISBN numbers -- ISBN-13 first | ||
Created attachment 32608 [details]
MARCXML file with multiple ISBN numbers -- ISBN-13 first
Stage and import this record.
Oh, the badness goes *so* much deeper: GetNormalizedISBN calls _isbn_cleanup():
sub _isbn_cleanup {
my ($isbn) = @_;
return NormalizeISBN(
{
isbn => $isbn,
format => 'ISBN-10',
strip_hyphens => 1,
}
) if $isbn;
}
... So if the first ISBN isn't a valid *10 digit* isbn, GetNormalizedISBN will fail.
I've attached a MARCXML record which will trigger the bug.
Could you describe an issue visible on the interface? |
If you take a look at C4::Koha::GetNormalizedISBN you will see code like this: if ($marcflavour eq 'UNIMARC') { @fields = $record->field('010'); foreach my $field (@fields) { my $isbn = $field->subfield('a'); if ($isbn) { return _isbn_cleanup($isbn); } else { return undef; } } } If I read this correctly, if we have say two ISBNs in a record, with the first being invalid and the second being valid, GetNormalizedISBN will still return undef because it never bothers to check the second isbn!