Bugzilla – Attachment 161721 Details for
Bug 32132
Missing budget_period_id in aqbudgets kills lateorders.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32132: Do not allow NULL value in column aqbudgets.budget_period_id
0001-Bug-32132-Do-not-allow-NULL-value-in-column-aqbudget.patch (text/plain), 2.98 KB, created by
Emmi Takkinen
on 2024-02-02 08:00:08 UTC
(
hide
)
Description:
Bug 32132: Do not allow NULL value in column aqbudgets.budget_period_id
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2024-02-02 08:00:08 UTC
Size:
2.98 KB
patch
obsolete
>From 4e72c505776f6213a25526630e2e978fcfbc016d Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Fri, 2 Feb 2024 09:02:59 +0200 >Subject: [PATCH] Bug 32132: Do not allow NULL value in column > aqbudgets.budget_period_id > >If budget_period_id column is set as NULL, "Late orders" >page dies on error 500. Logs read: > >Template process failed: undef error - DBIC result _type isn't of the _type Aqbudget at >/home/koha/Koha/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/lateorders.tt line 157 > >This patch makes changes to column aqbudgets.budget_period_id so that it >no longer allows NULL values. This is in line with aqbudgets tables foreign key >"budget_period_id" which has ON DELETE CASCADE clause. > >To test: >1. Run prove t/db_dependent/Koha/Acquisition/Fund.t >=> Tests should fail >2. Run updatedatabase.pl and restart services if needed >3. Rerun prove t/db_dependent/Koha/Acquisition/Fund.t >=> Tests should now pass > >Sponsored-by: Koha-Suomi Oy >--- > installer/data/mysql/atomicupdate/bug_32132.pl | 17 +++++++++++++++++ > t/db_dependent/Koha/Acquisition/Fund.t | 11 ++++++++++- > 2 files changed, 27 insertions(+), 1 deletion(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_32132.pl > >diff --git a/installer/data/mysql/atomicupdate/bug_32132.pl b/installer/data/mysql/atomicupdate/bug_32132.pl >new file mode 100755 >index 0000000000..f85fb7e084 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_32132.pl >@@ -0,0 +1,17 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "32132", >+ description => "Set aqbudgets.budget_period_id as NOT NULL", >+ up => sub { >+ my ($args) = @_; >+ my ( $dbh, $out ) = @$args{qw(dbh out)}; >+ >+ # Do you stuffs here >+ $dbh->do(q{ALTER TABLE aqbudgets MODIFY COLUMN `budget_period_id` INT(11) NOT NULL}); >+ >+ # Print useful stuff here >+ # tables >+ say $out "Change aqbudgets.budget_period_id to NOT accept NULL values."; >+ }, >+}; >diff --git a/t/db_dependent/Koha/Acquisition/Fund.t b/t/db_dependent/Koha/Acquisition/Fund.t >index 80c4e4e65a..fc21d0b38f 100755 >--- a/t/db_dependent/Koha/Acquisition/Fund.t >+++ b/t/db_dependent/Koha/Acquisition/Fund.t >@@ -20,6 +20,7 @@ > use Modern::Perl; > > use Test::More tests => 3; >+use Test::Warn; > > use t::lib::TestBuilder; > >@@ -57,7 +58,7 @@ subtest 'budget ()' => sub { > }; > > subtest 'budget' => sub { >- plan tests => 1; >+ plan tests => 2; > > $schema->storage->txn_begin; > my $f = $builder->build_object( >@@ -70,5 +71,13 @@ subtest 'budget' => sub { > is( ref( $fund->budget ), > 'Koha::Acquisition::Budget', > '->fund should return a Koha::Acquisition::Budget object' ); >+ >+ # Cannot set aqbudgets.budget_period_id as NULL >+ warning_like { >+ eval { $fund->budget_period_id(undef)->store } >+ } >+ qr{.*DBD::mysql::st execute failed: Column 'budget_period_id' cannot be null.*}, >+ 'DBD should have raised an error about budget_period_id that cannot be null'; >+ > $schema->storage->txn_rollback; > }; >-- >2.34.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 32132
:
143988
|
161721
|
162232
|
162233
|
162241
|
162584
|
165373
|
165374