From 136c49a940a632e9bcfb50694871b1a9ba2480c1 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 1 Dec 2017 15:21:56 +0000 Subject: [PATCH] Bug 19725: OAI-PMH - Use biblio_metadata.timestamp Since bug 17196, biblioitems.timestamp is not always updated after a change in the MARC record. Filtering should be based on biblio_metadata.timestamp instead. Test plan: 1. prove t/db_dependent/OAI/Server.t 2. Verify that it SUCCEEDS Signed-off-by: Josef Moravec Signed-off-by: Kyle M Hall Signed-off-by: Jonathan Druart --- Koha/OAI/Server/ListBase.pm | 6 +++--- t/db_dependent/OAI/Server.t | 14 +------------- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/Koha/OAI/Server/ListBase.pm b/Koha/OAI/Server/ListBase.pm index 0c7c56a13d..92af1c3661 100644 --- a/Koha/OAI/Server/ListBase.pm +++ b/Koha/OAI/Server/ListBase.pm @@ -58,7 +58,7 @@ sub GetRecords { # first deleted records ($deleted == 1), then normal records ($deleted == 0) STAGELOOP: for ( ; $deleted >= 0; $deleted-- ) { - my $table = $deleted ? 'deletedbiblioitems' : 'biblioitems'; + my $table = $deleted ? 'deletedbiblio_metadata' : 'biblio_metadata'; my $sql = " SELECT biblionumber FROM $table @@ -103,7 +103,7 @@ sub GetRecords { $sql = " SELECT MAX(timestamp) FROM ( - SELECT timestamp FROM deletedbiblioitems WHERE biblionumber = ? + SELECT timestamp FROM deletedbiblio_metadata WHERE biblionumber = ? UNION SELECT timestamp FROM deleteditems WHERE biblionumber = ? ) bis @@ -112,7 +112,7 @@ sub GetRecords { $sql = " SELECT MAX(timestamp) FROM ( - SELECT timestamp FROM biblioitems WHERE biblionumber = ? + SELECT timestamp FROM biblio_metadata WHERE biblionumber = ? UNION SELECT timestamp FROM deleteditems WHERE biblionumber = ? UNION diff --git a/t/db_dependent/OAI/Server.t b/t/db_dependent/OAI/Server.t index fa2d2a71ec..def867bffe 100644 --- a/t/db_dependent/OAI/Server.t +++ b/t/db_dependent/OAI/Server.t @@ -85,7 +85,6 @@ foreach my $index ( 0 .. NUMBER_OF_MARC_RECORDS - 1 ) { $sth->execute($biblionumber); my $timestamp = $sth->fetchrow_array . 'Z'; $timestamp =~ s/ /T/; - $timestamp = manipulate_timestamp( $index, $biblionumber, $timestamp ); $record = GetMarcBiblio({ biblionumber => $biblionumber }); $record = XMLin($record->as_xml_record); push @header, { datestamp => $timestamp, identifier => "TEST:$biblionumber" }; @@ -353,6 +352,7 @@ subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_me my $record = GetMarcBiblio({biblionumber => $biblionumber}); $record->append_fields(MARC::Field->new(999, '', '', z => '_')); ModBiblio($record, $biblionumber); + $oaidc[0]->{header}->{datestamp} = $from; test_query( 'ListRecords oai_dc with parameter from', @@ -364,15 +364,3 @@ subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_me }; $schema->storage->txn_rollback; - -sub manipulate_timestamp { -# This eliminates waiting a few seconds in order to get a higher timestamp -# Works only for 60 records.. - my ( $index, $bibno, $timestamp ) = @_; - return $timestamp if $timestamp !~ /\d{2}Z/; - my $secs = sprintf( "%02d", $index ); - $timestamp =~ s/\d{2}Z/${secs}Z/; - $dbh->do("UPDATE biblioitems SET timestamp=? WHERE biblionumber=?", undef, - ( $timestamp, $bibno )); - return $timestamp; -} -- 2.39.5