Bugzilla – Attachment 176159 Details for
Bug 30300
Add patron expiration email to patron messaging preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30300: (QA follow-up) Remove use of Koha:: and C4:: in DB Update
Bug-30300-QA-follow-up-Remove-use-of-Koha-and-C4-i.patch (text/plain), 3.13 KB, created by
Martin Renvoize (ashimema)
on 2025-01-06 15:28:05 UTC
(
hide
)
Description:
Bug 30300: (QA follow-up) Remove use of Koha:: and C4:: in DB Update
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-01-06 15:28:05 UTC
Size:
3.13 KB
patch
obsolete
>From e670d5c41eea41a30dc87532f91168a8f5c1bed4 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 6 Jan 2025 15:21:55 +0000 >Subject: [PATCH] Bug 30300: (QA follow-up) Remove use of Koha:: and C4:: in DB > Update > >We require that database updates don't rely on Koha:: or C4:: code to >reliably maintain idempotency (The underlying methods may change at a >future date). > >This approach uses two INSERT IGNORE statements which should also >improve performance. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > ...add_expiration_to_messaging_preferences.pl | 40 ++++++++++++------- > 1 file changed, 26 insertions(+), 14 deletions(-) > >diff --git a/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl b/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl >index d8f37cd236b..72d4fcdec13 100755 >--- a/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl >+++ b/installer/data/mysql/atomicupdate/bug_30300-add_expiration_to_messaging_preferences.pl >@@ -1,7 +1,5 @@ > use Modern::Perl; > >-use Koha::Patrons; >- > return { > bug_number => "30300", > description => "Add Patron expiry to messaging preference", >@@ -48,20 +46,34 @@ return { > say $out "MEMBERSHIP_EXPIRY added to message_transports"; > > my $days_notice = C4::Context->preference('MembershipExpiryDaysNotice'); >- if($days_notice) { >- my $patrons = Koha::Patrons->search(); >- while ( my $patron = $patrons->next ) { >- C4::Members::Messaging::SetMessagingPreference( >- { >- borrowernumber => $patron->borrowernumber, >- message_attribute_id => $message_attribute_id, >- message_transport_types => ['email'], >- } >- ); >- } >+ if ($days_notice) { >+ >+ $dbh->do( >+ q{ >+ INSERT IGNORE INTO borrower_message_preferences >+ (`borrower_message_preference_id`, `borrowernumber`, `categorycode`, `message_attribute_id`, `days_in_advance`, `wants_digest`) >+ SELECT >+ NULL, borrowernumber, NULL, ?, NULL, NULL >+ FROM >+ borrowers >+ }, {}, $message_attribute_id >+ ); >+ >+ $dbh->do( >+ q{ >+ INSERT IGNORE INTO borrower_message_transport_preferences >+ (`borrower_message_preference_id`, `message_transport_type`) >+ SELECT >+ borrower_message_preference_id, 'email' >+ FROM >+ borrower_message_preferences >+ WHERE >+ message_attribute_id = ? >+ }, {}, $message_attribute_id >+ ); > } > } else { > say $out "Patron_Expiry message attribute exists, skipping update"; > } > }, >- } >+}; >-- >2.47.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 30300
:
169860
|
169861
|
169870
|
169871
|
173810
|
173811
|
173812
|
173820
|
173821
|
173822
|
173823
|
174713
|
174714
|
174715
|
174716
|
174717
|
174888
|
176154
|
176155
|
176156
|
176157
|
176158
| 176159