Bugzilla – Attachment 67998 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: Replace the truncate option by reset_all
Bug-19452-Replace-the-truncate-option-by-resetall.patch (text/plain), 4.48 KB, created by
Marcel de Rooy
on 2017-10-12 12:41:00 UTC
(
hide
)
Description:
Bug 19452: Replace the truncate option by reset_all
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-10-12 12:41:00 UTC
Size:
4.48 KB
patch
obsolete
>From 016eba3c316acbcc1496b82717b197d5d77d839e 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: Replace the truncate option by reset_all >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. > >This patch replaces -truncate by -reset_all: >It will only delete records from borrower_message_preferences directly, >and skip patron categories. This allows you to reset all borrower prefs >to the untouched prefs from the patron category. >In a follow-up report I will propose to add a category parameter in order >to allow resetting prefs for specific categories. > >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 -reset_all >[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> >--- > .../borrowers-force-messaging-defaults.pl | 26 +++++++++++----------- > 1 file changed, 13 insertions(+), 13 deletions(-) > >diff --git a/misc/maintenance/borrowers-force-messaging-defaults.pl b/misc/maintenance/borrowers-force-messaging-defaults.pl >index cbff4f1..2945ad0 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, $actives, $no_overwrite) = @_; >+ my ($doit, $reset_all, $since, $actives, $no_overwrite) = @_; > > $since = '0000-00-00' if (!$since); > print "Since: $since\n"; >@@ -47,11 +47,8 @@ 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|); >+ if ( $doit && $reset_all ) { >+ $dbh->do(q|DELETE FROM borrower_message_preferences WHERE borrowernumber IS NOT NULL|); > } > > my $sql = "SELECT borrowernumber, categorycode FROM borrowers bo WHERE dateenrolled >= ?"; >@@ -75,10 +72,10 @@ sub force_borrower_messaging_defaults { > } > > >-my ( $doit, $truncate, $since, $help, $actives, $no_overwrite ); >+my ( $doit, $reset_all, $since, $help, $actives, $no_overwrite ); > my $result = GetOptions( > 'doit' => \$doit, >- 'truncate' => \$truncate, >+ 'reset_all' => \$reset_all, > 'since:s' => \$since, > 'actives' => \$actives, > 'no_overwrite' => \$no_overwrite, >@@ -86,8 +83,12 @@ my $result = GetOptions( > ); > > usage() if $help; >+if( $no_overwrite && $reset_all ) { >+ print "The options no_overwrite and reset_all are mutually exclusive\n"; >+ exit 1; >+} > >-force_borrower_messaging_defaults( $doit, $truncate, $since, $actives, $no_overwrite ); >+force_borrower_messaging_defaults( $doit, $reset_all, $since, $actives, $no_overwrite ); > > =head1 NAME > >@@ -98,7 +99,7 @@ force-borrower-messaging-defaults > force-borrower-messaging-defaults > force-borrower-messaging-defaults --help > force-borrower-messaging-defaults --doit >- force-borrower-messaging-defaults --doit --truncate >+ force-borrower-messaging-defaults --doit --reset_all > force-borrower-messaging-defaults --doit --actives > > =head1 DESCRIPTION >@@ -123,10 +124,9 @@ Prints this help > > Actually update the borrowers. > >-=item B<--truncate> >+=item B<--reset_all> > >-Truncate all borrowers transport preferences before (re-)creating them. It >-affects borrower_message_preferences table. >+Removes all borrowers messaging preferences before (re-)creating them. > > =item B<--actives> > >-- >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