Bug 11469

Summary: Publication date range assumes that years must always be 4 digits
Product: Koha Reporter: Katrin Fischer <katrin.fischer>
Component: SearchingAssignee: Jonathan Druart <jonathan.druart>
Status: Failed QA --- QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: jonathan.druart, martin.renvoize, nick
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 11469: Allow search by publication years with number of digits != 4
Bug 11469: Allow search by publication years with number of digits != 4
Bug 11469: Fix search by date range

Description Katrin Fischer 2014-01-02 15:42:42 UTC
This came up in a project where Koha is used for old manuscripts. The publication date range search will not work if a user enters years < 1000:

opac-search.pl:

418 # append year limits if they exist
419 if ($params->{'limit-yr'}) {
420     if ($params->{'limit-yr'} =~ /\d{4}-\d{4}/) {
421         my ($yr1,$yr2) = split(/-/, $params->{'limit-yr'});
422         push @limits, "yr,st-numeric,ge=$yr1 and yr,st-numeric,le=$yr2";
423     }
424     elsif ($params->{'limit-yr'} =~ /\d{4}/) {
425         push @limits, "yr,st-numeric=$params->{'limit-yr'}";
426     }
427     else {
428         #FIXME: Should return a error to the user, incorect date format specified
429     }
430 }
Comment 1 Jonathan Druart 2020-07-31 10:08:36 UTC
Created attachment 107628 [details] [review]
Bug 11469: Allow search by publication years with number of digits != 4

The adv search did not allow publication years prior to 1000
We are now ready for year 10000

Test plan:
Having some book with a publication year=123 (3 digits)
Search this book by publication year
=> Search result must return it
Comment 2 Martin Renvoize 2020-08-05 16:35:52 UTC
Created attachment 107848 [details] [review]
Bug 11469: Allow search by publication years with number of digits != 4

The adv search did not allow publication years prior to 1000
We are now ready for year 10000

Test plan:
Having some book with a publication year=123 (3 digits)
Search this book by publication year
=> Search result must return it

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 3 Martin Renvoize 2020-08-05 16:37:56 UTC
Simple patch that works as expected.. must admit I was expecting us to be doing something 'clever' like catching double-digit dates adding a prefix to make it up to four digits.. but as we're not doing anything like that already this patch seems perfect.

Signing off.
Comment 4 Katrin Fischer 2020-08-05 20:14:33 UTC
> The adv search did not allow publication years prior to 1000
> We are now ready for year 10000

We might be - but MARC definitely is not :)
Comment 5 Nick Clemens 2020-08-06 14:26:31 UTC
Before patch, on opac, search 'Date range: 1990-2000'
Succeeds

After:
fails
Comment 6 Jonathan Druart 2020-08-07 07:20:14 UTC
Created attachment 107939 [details] [review]
Bug 11469: Fix search by date range
Comment 7 Katrin Fischer 2020-08-15 07:48:07 UTC
Did some more testing, now -2007 doesn't seem to work with the patches :(