(bug #4491) fix weird code in search scripts
[koha.git] / opac / oai.pl
index d1fa059..546623e 100755 (executable)
@@ -11,7 +11,7 @@ use C4::Context;
 
 BEGIN {
     eval { require PerlIO::gzip };
-    $GZIP = $@ ? 0 : 1;
+    $GZIP = ($@) ? 0 : 1;
 }
 
 unless ( C4::Context->preference('OAI-PMH') ) {
@@ -125,7 +125,13 @@ sub new {
         earliestDatestamp   => '0001-01-01',
         deletedRecord       => 'no',
     );
-    $self->description( "Koha OAI Repository" );
+
+    # FIXME - alas, the description element is not so simple; to validate
+    # against the OAI-PMH schema, it cannot contain just a string,
+    # but one or more elements that validate against another XML schema.
+    # For now, simply omitting it.
+    # $self->description( "Koha OAI Repository" );
+
     $self->compression( 'gzip' );
 
     return $self;
@@ -285,7 +291,7 @@ sub new {
         metadataPrefix  => $token->{metadata_prefix},
         from            => $token->{from},
         until           => $token->{until},
-        offset          => $pos ) );
+        offset          => $pos ) ) if ($pos > $token->{offset});
 
     return $self;
 }
@@ -332,7 +338,7 @@ sub new {
         metadataPrefix  => $token->{metadata_prefix},
         from            => $token->{from},
         until           => $token->{until},
-        offset          => $pos ) );
+        offset          => $pos ) ) if ($pos > $token->{offset});
 
     return $self;
 }