Bugzilla – Attachment 71652 Details for
Bug 19452
The -truncate option in borrowers-force-messaging-defaults.pl should not remove category preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19452: Remove the truncate option
Bug-19452-Remove-the-truncate-option.patch (text/plain), 4.04 KB, created by
Marcel de Rooy
on 2018-02-15 13:20:24 UTC
(
hide
)
Description:
Bug 19452: Remove the truncate option
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-02-15 13:20:24 UTC
Size:
4.04 KB
patch
obsolete
>From d3a169b1448f11ae990081492acedb460877051f Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 12 Oct 2017 13:13:41 +0200 >Subject: [PATCH] Bug 19452: Remove the truncate option >Content-Type: text/plain; charset=utf-8 > >The truncate option is not really useful. Its result is probably not what >most users of this script expect or need. >It truncates both tables borrower_message_preferences and >borrower_message_transport_preferences. This (unfortunately) includes >deleting messaging preferences for patron categories. After that, adding >preferences again will not add categories again, but only borrower >preferences which are all disabled. > >Furthermore, we do not need to disable the foreign key check. Neither >do we actually need to truncate, deleting records seems sufficient. >Also deleting transport preferences is not needed, since it will be >done by a cascade from messaging preferences. Note that the subsequent >call of SetMessagingPreferencesFromDefaults will already delete the >records. > >This makes it possible to remove the truncate option altogether. > >Test plan: >[1] Select a patron category (say ST) and change days_in_advance to x. >[2] Select a ST patron and set days_advance to y in his msg prefs. >[3] Run borrowers-force-messaging-defaults.pl -doit >[4] Verify that the patron has been reset to the default prefs (incl. > value x in days_in_advance). >[5] Verify that the patron category prefs are still intact. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Charles Farmer <charles.farmer@inLibro.com> >--- > .../borrowers-force-messaging-defaults.pl | 20 +++----------------- > 1 file changed, 3 insertions(+), 17 deletions(-) > >diff --git a/misc/maintenance/borrowers-force-messaging-defaults.pl b/misc/maintenance/borrowers-force-messaging-defaults.pl >index 72e8c95..bd7a00f 100755 >--- a/misc/maintenance/borrowers-force-messaging-defaults.pl >+++ b/misc/maintenance/borrowers-force-messaging-defaults.pl >@@ -39,7 +39,7 @@ sub usage { > > > sub force_borrower_messaging_defaults { >- my ($doit, $truncate, $since, $not_expired, $no_overwrite) = @_; >+ my ($doit, $since, $not_expired, $no_overwrite) = @_; > > $since = '0000-00-00' if (!$since); > print "Since: $since\n"; >@@ -47,13 +47,6 @@ sub force_borrower_messaging_defaults { > my $dbh = C4::Context->dbh; > $dbh->{AutoCommit} = 0; > >- if ( $doit && $truncate ) { >- $dbh->do(q|SET FOREIGN_KEY_CHECKS = 0|); >- $dbh->do(q|TRUNCATE borrower_message_transport_preferences|); >- $dbh->do(q|TRUNCATE borrower_message_preferences|); >- $dbh->do(q|SET FOREIGN_KEY_CHECKS = 1|); >- } >- > my $sql = > q|SELECT DISTINCT bo.borrowernumber, bo.categorycode FROM borrowers bo > LEFT JOIN borrower_message_preferences mp USING (borrowernumber) >@@ -78,10 +71,9 @@ WHERE bo.dateenrolled >= ?|; > } > > >-my ( $doit, $truncate, $since, $help, $not_expired, $no_overwrite ); >+my ( $doit, $since, $help, $not_expired, $no_overwrite ); > my $result = GetOptions( > 'doit' => \$doit, >- 'truncate' => \$truncate, > 'since:s' => \$since, > 'not-expired' => \$not_expired, > 'no-overwrite' => \$no_overwrite, >@@ -90,7 +82,7 @@ my $result = GetOptions( > > usage() if $help; > >-force_borrower_messaging_defaults( $doit, $truncate, $since, $not_expired, $no_overwrite ); >+force_borrower_messaging_defaults( $doit, $since, $not_expired, $no_overwrite ); > > =head1 NAME > >@@ -101,7 +93,6 @@ borrowers-force-messaging-defaults.pl > borrowers-force-messaging-defaults.pl > borrowers-force-messaging-defaults.pl --help > borrowers-force-messaging-defaults.pl --doit >- borrowers-force-messaging-defaults.pl --doit --truncate > borrowers-force-messaging-defaults.pl --doit --not-expired > > =head1 DESCRIPTION >@@ -126,11 +117,6 @@ Prints this help > > Actually update the borrowers. > >-=item B<--truncate> >- >-Truncate all borrowers transport preferences before (re-)creating them. It >-affects borrower_message_preferences table. >- > =item B<--not-expired> > > Will only update active borrowers (borrowers who didn't pass their expiration date). >-- >2.1.4
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 19452
:
67998
|
68175
|
68201
|
69203
|
71652
|
71815
|
72000
|
72001