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 <josef.moravec@gmail.com>

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

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Julian Maurice 2017-12-01 15:21:56 +00:00 committed by Jonathan Druart
parent c867cadeef
commit 136c49a940
2 changed files with 4 additions and 16 deletions

View File

@ -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

View File

@ -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;
}