Bug 33368: Extends borrowers.flags to bigint

it's a int(11) which means its limit is 2^31

We have currently 29 permissions, there is only one remaining, at 31 permissions
the permission system won't support a case where a patron has all permissions.

Test plan:
Don't apply this patch
Add another permission
INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES (30, 'new permission 1', '', 0) ;
Go to the interface, tick all the boxes
select flags from borrowers where borrowernumber=5;
=> 2113928830
Remember:
2^31  2147483648
2^32  4294967296

Add another one
INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES (31, 'new permission 2', '', 0) ;
Repeat the step before
=> boom
CGI::Compile::ROOT::kohadevbox_koha_members_member_2dflags_2epl::member_2dflags_2epl(): DBI Exception: DBD::mysql::st execute failed: Out of range value for column 'flags' at row 1 at /usr/share/perl5/CGI/Emulate/PSGI.pm line 30

Apply the patch, try again

QA note: That's ofc not the best solution, but the easiest for now

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit e81612c719)
Signed-off-by: Jacob O'Mara <jacobomara901@gmail.com>
This commit is contained in:
Jonathan Druart 2023-03-30 09:58:30 +02:00 committed by Jacob O'Mara
parent 593b45dcb1
commit d978e86b2d
2 changed files with 25 additions and 3 deletions

View File

@ -0,0 +1,22 @@
use Modern::Perl;
return {
bug_number => "33368",
description => "Extend borrowers.flags to bigint",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
$dbh->do(q{
ALTER TABLE borrower_modifications
MODIFY COLUMN `flags` bigint(11)
});
$dbh->do(q{
ALTER TABLE borrowers
MODIFY COLUMN `flags` bigint(11) DEFAULT NULL COMMENT 'will include a number associated with the staff member''s permissions'
});
$dbh->do(q{
ALTER TABLE deletedborrowers
MODIFY COLUMN `flags` bigint(11) DEFAULT NULL COMMENT 'will include a number associated with the staff member''s permissions'
});
},
};

View File

@ -1323,7 +1323,7 @@ CREATE TABLE `borrower_modifications` (
`relationship` varchar(100) DEFAULT NULL,
`sex` varchar(1) DEFAULT NULL,
`password` varchar(30) DEFAULT NULL,
`flags` int(11) DEFAULT NULL,
`flags` bigint(11) DEFAULT NULL,
`userid` varchar(75) DEFAULT NULL,
`opacnote` longtext DEFAULT NULL,
`contactnote` varchar(255) DEFAULT NULL,
@ -1446,7 +1446,7 @@ CREATE TABLE `borrowers` (
`password` varchar(60) DEFAULT NULL COMMENT 'patron/borrower''s Bcrypt encrypted password',
`secret` mediumtext DEFAULT NULL COMMENT 'Secret for 2FA',
`auth_method` enum('password','two-factor') NOT NULL DEFAULT 'password' COMMENT 'Authentication method',
`flags` int(11) DEFAULT NULL COMMENT 'will include a number associated with the staff member''s permissions',
`flags` bigint(11) DEFAULT NULL COMMENT 'will include a number associated with the staff member''s permissions',
`userid` varchar(75) DEFAULT NULL COMMENT 'patron/borrower''s opac and/or staff interface log in',
`opacnote` longtext DEFAULT NULL COMMENT 'a note on the patron/borrower''s account that is visible in the OPAC and staff interface',
`contactnote` varchar(255) DEFAULT NULL COMMENT 'a note related to the patron/borrower''s alternate address',
@ -2569,7 +2569,7 @@ CREATE TABLE `deletedborrowers` (
`password` varchar(60) DEFAULT NULL COMMENT 'patron/borrower''s encrypted password',
`secret` mediumtext DEFAULT NULL COMMENT 'Secret for 2FA',
`auth_method` enum('password','two-factor') NOT NULL DEFAULT 'password' COMMENT 'Authentication method',
`flags` int(11) DEFAULT NULL COMMENT 'will include a number associated with the staff member''s permissions',
`flags` bigint(11) DEFAULT NULL COMMENT 'will include a number associated with the staff member''s permissions',
`userid` varchar(75) DEFAULT NULL COMMENT 'patron/borrower''s opac and/or staff interface log in',
`opacnote` longtext DEFAULT NULL COMMENT 'a note on the patron/borrower''s account that is visible in the OPAC and staff interface',
`contactnote` varchar(255) DEFAULT NULL COMMENT 'a note related to the patron/borrower''s alternate address',