Bugzilla – Attachment 162232 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), 4.19 KB, created by
Emmi Takkinen
on 2024-02-16 06:12:38 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-16 06:12:38 UTC
Size:
4.19 KB
patch
obsolete
>From b454b85f43eebfe2af586231f2de733fffefe2af 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 1/2] 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 +++++++++++++++++ > installer/data/mysql/kohastructure.sql | 2 +- > t/db_dependent/Koha/Acquisition/Fund.t | 11 ++++++++++- > 3 files changed, 28 insertions(+), 2 deletions(-) > 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/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 16310f0f44..8834a5e273 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -559,7 +559,7 @@ CREATE TABLE `aqbudgets` ( > `budget_expend` decimal(28,6) DEFAULT 0.000000 COMMENT 'budget warning at amount', > `budget_notes` longtext DEFAULT NULL COMMENT 'notes related to this fund', > `timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'date and time this fund was last touched (created or modified)', >- `budget_period_id` int(11) DEFAULT NULL COMMENT 'id of the budget that this fund belongs to (aqbudgetperiods.budget_period_id)', >+ `budget_period_id` int(11) NOT NULL COMMENT 'id of the budget that this fund belongs to (aqbudgetperiods.budget_period_id)', > `sort1_authcat` varchar(80) DEFAULT NULL COMMENT 'statistical category for this fund', > `sort2_authcat` varchar(80) DEFAULT NULL COMMENT 'second statistical category for this fund', > `budget_owner_id` int(11) DEFAULT NULL COMMENT 'borrowernumber of the person who owns this fund (borrowers.borrowernumber)', >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