Bug 11469 - Publication date range assumes that years must always be 4 digits
Summary: Publication date range assumes that years must always be 4 digits
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: Searching (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-02 15:42 UTC by Katrin Fischer
Modified: 2020-08-15 07:48 UTC (History)
3 users (show)

See Also:
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 (1.50 KB, patch)
2020-07-31 10:08 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 11469: Allow search by publication years with number of digits != 4 (1.57 KB, patch)
2020-08-05 16:35 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 11469: Fix search by date range (1.24 KB, patch)
2020-08-07 07:20 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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 :(