Bugzilla – Attachment 101765 Details for
Bug 24614
Can't edit reports if not using cache
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24614: Use Koha::Reports from save_report and update_sql
Bug-24614-Use-KohaReports-from-savereport-and-upda.patch (text/plain), 4.21 KB, created by
Kyle M Hall (khall)
on 2020-03-25 19:00:54 UTC
(
hide
)
Description:
Bug 24614: Use Koha::Reports from save_report and update_sql
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-03-25 19:00:54 UTC
Size:
4.21 KB
patch
obsolete
>From b8a9e07d98630552c7f086d4bced96d74d8e91e1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 11 Feb 2020 17:21:38 +0100 >Subject: [PATCH] Bug 24614: Use Koha::Reports from save_report and update_sql > >In order to get the default value defined at DBMS level, we use >Koha::Reports (to inherit from Koha::Object->store) from the 2 add/edit >methods of C4::Reports::Guided. >A second step would be to remove completely those CRUD subroutines and >use directly Koha::Reports instead. > >Test plan: >1. Add and edit some reports >2. Disable memcached, create a report, edit it >=> Should not crash >3. Make sure the tests make sense and that they pass after the second >patch. > >The error was: >DBD::mysql::db do failed: Column 'cache_expiry' cannot be null [for >Statement "UPDATE saved_sql SET savedsql = ?, last_modified = now(), >report_name = ?, report_group = ?, report_subgroup = ?, notes = ?, >cache_expiry = ?, public = ? WHERE id = ? "] at >/kohadevbox/koha/C4/Reports/Guided.pm line 633. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Reports/Guided.pm | 43 +++++++++++++++++++++++++++++++------------ > 1 file changed, 31 insertions(+), 12 deletions(-) > >diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm >index 61aa804628..01a613dbf9 100644 >--- a/C4/Reports/Guided.pm >+++ b/C4/Reports/Guided.pm >@@ -599,17 +599,29 @@ sub save_report { > my $area = $fields->{area}; > my $group = $fields->{group}; > my $subgroup = $fields->{subgroup}; >- my $cache_expiry = $fields->{cache_expiry} || 300; >+ my $cache_expiry = $fields->{cache_expiry}; > my $public = $fields->{public}; > >- my $dbh = C4::Context->dbh(); > $sql =~ s/(\s*\;\s*)$//; # removes trailing whitespace and /;/ >- my $query = "INSERT INTO saved_sql (borrowernumber,date_created,last_modified,savedsql,report_name,report_area,report_group,report_subgroup,type,notes,cache_expiry,public) VALUES (?,now(),now(),?,?,?,?,?,?,?,?,?)"; >- $dbh->do($query, undef, $borrowernumber, $sql, $name, $area, $group, $subgroup, $type, $notes, $cache_expiry, $public); >+ my $now = dt_from_string; >+ my $report = Koha::Report->new( >+ { >+ borrowernumber => $borrowernumber, >+ date_created => $now, # Must be moved to Koha::Report->store >+ last_modified => $now, # Must be moved to Koha::Report->store >+ savedsql => $sql, >+ report_name => $name, >+ report_area => $area, >+ report_group => $group, >+ report_subgroup => $subgroup, >+ type => $type, >+ notes => $notes, >+ cache_expiry => $cache_expiry, >+ public => $public, >+ } >+ )->store; > >- my $id = $dbh->selectrow_array("SELECT max(id) FROM saved_sql WHERE borrowernumber=? AND report_name=?", undef, >- $borrowernumber, $name); >- return $id; >+ return $report->id; > } > > sub update_sql { >@@ -623,14 +635,21 @@ sub update_sql { > my $cache_expiry = $fields->{cache_expiry}; > my $public = $fields->{public}; > >+ $sql =~ s/(\s*\;\s*)$//; # removes trailing whitespace and /;/ >+ my $report = Koha::Reports->find($id); >+ $report->last_modified(dt_from_string); >+ $report->savedsql($sql); >+ $report->report_name($name); >+ $report->notes($notes); >+ $report->report_group($group); >+ $report->report_subgroup($subgroup); >+ $report->cache_expiry($cache_expiry) if defined $cache_expiry; >+ $report->public($public); > if( $cache_expiry >= 2592000 ){ >- die "Please specify a cache expiry less than 30 days\n"; >+ die "Please specify a cache expiry less than 30 days\n"; # That's a bit harsh > } > >- my $dbh = C4::Context->dbh(); >- $sql =~ s/(\s*\;\s*)$//; # removes trailing whitespace and /;/ >- my $query = "UPDATE saved_sql SET savedsql = ?, last_modified = now(), report_name = ?, report_group = ?, report_subgroup = ?, notes = ?, cache_expiry = ?, public = ? WHERE id = ? "; >- $dbh->do($query, undef, $sql, $name, $group, $subgroup, $notes, $cache_expiry, $public, $id ); >+ return $report; > } > > sub store_results { >-- >2.21.1 (Apple Git-122.3)
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 24614
:
98714
|
98715
|
101700
|
101701
|
101764
| 101765 |
102013