Bugzilla – Attachment 138436 Details for
Bug 31158
Can't filter suggestions by date ranges
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31158: (bug 23991 follow-up) Fix suggestion search by dates
Bug-31158-bug-23991-follow-up-Fix-suggestion-searc.patch (text/plain), 2.57 KB, created by
Jonathan Druart
on 2022-08-01 06:16:37 UTC
(
hide
)
Description:
Bug 31158: (bug 23991 follow-up) Fix suggestion search by dates
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-08-01 06:16:37 UTC
Size:
2.57 KB
patch
obsolete
>From c20e697f804f4bf1bc63b9ff28607d81fe9f7488 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 1 Aug 2022 08:14:27 +0200 >Subject: [PATCH] Bug 31158: (bug 23991 follow-up) Fix suggestion search by > dates > >Search suggestions by date is broken, we don't remove the '_from' CGI >params for the DBIC query >DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::mysql::st execute failed: Unknown column 'suggesteddate_from' in 'where clause' at /kohadevbox/koha/Koha/Objects.pm line 394 > at /usr/share/perl5/DBIx/Class/Exception.pm line 77 > >Test plan: >Create some suggestions, search for them using date range (suggested >date, managed date and accepted date) >--- > suggestion/suggestion.pl | 21 ++++++++------------- > 1 file changed, 8 insertions(+), 13 deletions(-) > >diff --git a/suggestion/suggestion.pl b/suggestion/suggestion.pl >index c38367256f0..e0c571b8aae 100755 >--- a/suggestion/suggestion.pl >+++ b/suggestion/suggestion.pl >@@ -384,25 +384,20 @@ if ($op=~/else/) { > > # filter on date fields > foreach my $field (qw( suggesteddate manageddate accepteddate )) { >- my $from = $field . "_from"; >- my $to = $field . "_to"; >- my $from_dt = >- $suggestion_ref->{$from} >- ? eval { dt_from_string( $suggestion_ref->{$from} ) } >- : undef; >- my $to_dt = >- $suggestion_ref->{$to} >- ? eval { dt_from_string( $suggestion_ref->{$to} ) } >- : undef; >+ my $from = delete $search_params->{"${field}_from"}; >+ my $to = delete $search_params->{"${field}_to"}; >+ >+ my $from_dt = $from && eval { dt_from_string($from) }; >+ my $to_dt = $to && eval { dt_from_string($to) }; > > if ( $from_dt || $to_dt ) { > my $dtf = Koha::Database->new->schema->storage->datetime_parser; > if ( $from_dt && $to_dt ) { >- $search_params->{$field} = { -between => [ $from_dt, $to_dt ] }; >+ $search_params->{$field} = { -between => [ $dtf->format_date($from_dt), $dtf->format_date($to_dt) ] }; > } elsif ( $from_dt ) { >- $search_params->{$field} = { '>=' => $from_dt }; >+ $search_params->{$field} = { '>=' => $dtf->format_date($from_dt) }; > } elsif ( $to_dt ) { >- $search_params->{$field} = { '<=' => $to_dt }; >+ $search_params->{$field} = { '<=' => $dtf->format_date($to_dt) }; > } > } > } >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31158
:
138436
|
138519
|
138762
|
138930