Bugzilla – Attachment 155501 Details for
Bug 34589
Update on bug 20256 is not idempotent
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34589: Only update users if permission is added
Bug-34589-Only-update-users-if-permission-is-added.patch (text/plain), 2.68 KB, created by
Emily-Rose Francoeur
on 2023-09-11 16:05:12 UTC
(
hide
)
Description:
Bug 34589: Only update users if permission is added
Filename:
MIME Type:
Creator:
Emily-Rose Francoeur
Created:
2023-09-11 16:05:12 UTC
Size:
2.68 KB
patch
obsolete
>From c3e9bed7d64373e8c0c711f4cfba21599fe64eaf Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 22 Aug 2023 15:09:17 +0000 >Subject: [PATCH] Bug 34589: Only update users if permission is added >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >To test: >1 - Assign a user 'edit_items' permission >2 - Manually run the update > perl -e 'use C4::Installer; warn Data::Dumper::Dumper(C4::Installer::run_db_rev("installer/data/mysql/db_revs/221200003.pl"));' >3 - Edit patron permissions >4 - Note they now have edit_any_item permission >5 - Remove that permission >6 - Run the update again >7 - Edit patron permissions >8 - They have edit_any_item again - remove it >9 - Apply patch >10 - Run the update >11 - Edit patron permissions >12 - No new permissions added! >13 - sudo koha-mysql kohadev > DELETE FROM permissions WHERE code = 'edit_any_item' >14 - Run the update again >15 - Edit patron permissions >16 - They do have edit_any_item > >Signed-off-by: Ãmily-Rose Francoeur <emily-rose.francoeur@inLibro.com> >--- > installer/data/mysql/db_revs/221200003.pl | 22 +++++++++++++--------- > 1 file changed, 13 insertions(+), 9 deletions(-) > >diff --git a/installer/data/mysql/db_revs/221200003.pl b/installer/data/mysql/db_revs/221200003.pl >index 2df9e03d06..672e9cc674 100755 >--- a/installer/data/mysql/db_revs/221200003.pl >+++ b/installer/data/mysql/db_revs/221200003.pl >@@ -7,18 +7,22 @@ return { > my ($args) = @_; > my ($dbh, $out) = @$args{qw(dbh out)}; > >- $dbh->do(q{ >+ my $permission_added = $dbh->do(q{ > INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ( 9, 'edit_any_item', 'Edit any item reguardless of home library'); > }); >- say $out "Added new permission 'edit_any_item'"; > >- $dbh->do(q{ >- INSERT IGNORE INTO user_permissions ( borrowernumber, module_bit, code ) >- SELECT borrowernumber, '9', 'edit_any_item' >- FROM user_permissions >- WHERE module_bit = '9' >- AND code = 'edit_items' >- }); >+ if( $permission_added == 1 ){ >+ say $out "Added new permission 'edit_any_item'"; >+ >+ $dbh->do(q{ >+ INSERT IGNORE INTO user_permissions ( borrowernumber, module_bit, code ) >+ SELECT borrowernumber, '9', 'edit_any_item' >+ FROM user_permissions >+ WHERE module_bit = '9' >+ AND code = 'edit_items' >+ }); >+ say $out "Added 'edit_any_item' permission to users with edit items permission"; >+ } > > if ( !column_exists( 'library_groups', 'ft_limit_item_editing' ) ) { > $dbh->do(q{ >-- >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 34589
:
154702
|
155271
|
155501
|
155634