Bug 14363

Summary: OAI-PMH should handle records without marcxml
Product: Koha Reporter: Sophie MEYNIEUX <sophie.meynieux>
Component: Web servicesAssignee: Julian Maurice <julian.maurice>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: brendan, f.demians, julian.maurice, mirko
Version: 3.20   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Sometimes, some biblioitems records have empty marcxml. In this case, OAI harvester fails with a software error: Can't call method &quot;as_xml&quot; on an undefined value at /home/koha/src/opac/oai.pl line 516. Instead, now, record is skipped, and a mess
Version(s) released in:
Attachments: Bug 14363: OAI-PMH: Handle records without marcxml
Bug 14363: OAI-PMH: Handle records without marcxml
Bug 14363: OAI-PMH: Handle records without marcxml

Description Sophie MEYNIEUX 2015-06-08 13:16:11 UTC
I know it should not happen, but sometimes it does, some biblioitems have got an empty marcxml. 

In this case, OAI harvester fails with a software error :
<pre>Can't call method &quot;as_xml&quot; on an undefined value at /home/koha/src/opac/oai.pl line 516.

Instead it should skip this record, output a message in log file, and correctly harvest the other records.
Comment 1 Julian Maurice 2015-09-01 07:40:14 UTC
In master, due to bug 3206, a biblio without marcxml is considered deleted and thus there is no error.

However, something can be done for stable versions.

In 3.18.x and 3.20.x, oai.pl fails with the following error:

<pre>Empty String at /home/koha/src/opac/oai.pl line 228
Comment 2 Julian Maurice 2015-09-01 07:48:31 UTC Comment hidden (obsolete)
Comment 3 Julian Maurice 2015-09-01 07:48:56 UTC
Patch is for 3.20.x but should apply well on 3.18.x as well
Comment 4 Mirko Tietgen 2015-09-04 11:35:45 UTC
Needs a test plan.
Comment 5 Julian Maurice 2015-09-29 13:45:35 UTC
Test plan:

1/ git checkout 3.18.x
2/ GET http://OPAC/cgi-bin/koha/oai.pl?verb=ListRecords&metadataPrefix=marcxml
3/ Take the first biblionumber from the results ($biblionumber)
4/ mysql> update biblioitems set marcxml=null where biblionumber=$biblionumber
5/ Repeat step 2 => XML error
6/ Apply patch
7/ Repeat step 2 => no errors
Comment 6 Frédéric Demians 2015-12-08 12:22:52 UTC Comment hidden (obsolete)
Comment 7 Jonathan Druart 2015-12-08 15:34:57 UTC
Created attachment 45499 [details] [review]
Bug 14363: OAI-PMH: Handle records without marcxml

Test plan:

1/ git checkout 3.18.x
2/ GET http://OPAC/cgi-bin/koha/oai.pl?verb=ListRecords&metadataPrefix=marcxml
3/ Take the first biblionumber from the results ($biblionumber)
4/ mysql> update biblioitems set marcxml=null where biblionumber=$biblionumber
5/ Repeat step 2 => XML error
6/ Apply patch
7/ Repeat step 2 => no errors

Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
  Works on 3.20.x

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Fix works for 3.18.x and 3.20.x
3.22 is not impacted
Comment 8 Brendan Gallagher 2016-03-02 01:04:40 UTC
3.22 (and) Master isn't effected - making a note for the RMaint.  Thanks
Comment 9 Frédéric Demians 2016-03-03 07:30:45 UTC
Pushed in 3.20.8.