Bugzilla – Attachment 72109 Details for
Bug 13287
Add a system preference to define the number of days used in purge_suggestions.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13287: (QA follow-up) Final polishing
Bug-13287-QA-follow-up-Final-polishing.patch (text/plain), 3.67 KB, created by
Marcel de Rooy
on 2018-02-23 10:45:11 UTC
(
hide
)
Description:
Bug 13287: (QA follow-up) Final polishing
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-02-23 10:45:11 UTC
Size:
3.67 KB
patch
obsolete
>From 695f7b106b9b63aeef5fa012986a22a7646c5912 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 23 Feb 2018 10:33:49 +0100 >Subject: [PATCH] Bug 13287: (QA follow-up) Final polishing >Content-Type: text/plain; charset=utf-8 > >Cosmetic changes. >And: adding a confirm flag (see earlier comment too). Without this flag but >with having a filled pref, the script would purge when you do not pass any >parameter. This might not be appreciated. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > misc/cronjobs/crontab.example | 2 +- > misc/cronjobs/purge_suggestions.pl | 41 ++++++++++++++------------------------ > 2 files changed, 16 insertions(+), 27 deletions(-) > >diff --git a/misc/cronjobs/crontab.example b/misc/cronjobs/crontab.example >index f3dad73..db1c703 100644 >--- a/misc/cronjobs/crontab.example >+++ b/misc/cronjobs/crontab.example >@@ -90,7 +90,7 @@ KOHA_CRON_PATH = /usr/share/koha/bin/cronjobs > 16 1 * * * __KOHA_USER__ $KOHA_CRON_PATH/cleanup_database.pl --sessions --zebraqueue 10 --list-invites --temp-uploads > > # delete old purchase suggestions weekly. Replace XX with a number to define the age of suggestions to delete. >-@weekly __KOHA_USER__ $KOHA_CRON_PATH/purge_suggestions.pl --days XX > /dev/null 2>&1 >+@weekly __KOHA_USER__ $KOHA_CRON_PATH/purge_suggestions.pl --confirm --days XX > /dev/null 2>&1 > > # share_usage_with_koha_community.pl every months > 0 0 1 * * __KOHA_USER__ $KOHA_CRON_PATH/share_usage_with_koha_community.pl >diff --git a/misc/cronjobs/purge_suggestions.pl b/misc/cronjobs/purge_suggestions.pl >index 6dff5db..543d629 100755 >--- a/misc/cronjobs/purge_suggestions.pl >+++ b/misc/cronjobs/purge_suggestions.pl >@@ -18,10 +18,8 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use utf8; > > BEGIN { >- > # find Koha's Perl modules > # test carefully before changing this > use FindBin; >@@ -34,48 +32,39 @@ use C4::Suggestions; > use C4::Log; > use C4::Context; > >-my ( $help, $days ); >+my ( $help, $days, $confirm ); > > GetOptions( > 'help|?' => \$help, >- 'days=s' => \$days, >+ 'days:i' => \$days, >+ 'confirm'=> \$confirm, > ); > > my $usage = << 'ENDUSAGE'; >-This script delete old suggestions >+This script deletes old suggestions > Parameters: > -help|? This message > -days TTT to define the age of suggestions to delete >+-confirm flag needed to confirm purge operation >+ >+The days parameter falls back to the value of system preference >+PurgeSuggestionsOlderThan. Suggestions are deleted only for a positive >+number of days. > > Example: > ENDUSAGE >-$usage .= $0 . " -days 30\n"; >+$usage .= $0 . " -confirm -days 30\n"; > > # If this script is called without the 'days' parameter, we use the system preferences value instead. >-if ( !defined($days) && !$help ) { >- my $purge_sugg_days = >- C4::Context->preference('PurgeSuggestionsOlderThan') || q{}; >- if ( $purge_sugg_days ne q{} and $purge_sugg_days >= 0 ) { >- $days = $purge_sugg_days; >- } >-} >+$days = C4::Context->preference('PurgeSuggestionsOlderThan') if !defined($days); > > # If this script is called with the 'help' parameter, we show up the help message and we leave the script without doing anything. >-if ($help) { >+if( !$confirm || $help || !defined($days) ) { >+ print "No confirm parameter passed!\n\n" if !$confirm && !$help; > print $usage; >- exit; >-} >- >-if ( defined($days) && $days ne q{} && $days > 0 ) { >+} elsif( $days > 0 ) { > cronlogaction(); > DelSuggestionsOlderThan($days); >-} >-elsif (!defined($days)){ >- print $usage; >-} >-elsif ( $days == 0 ) { >- warn "This script is not executed with 0 days. Aborted.\n"; >-} >-else { >+} else { > warn "This script requires a positive number of days. Aborted.\n"; > } >-- >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 13287
:
33661
|
41219
|
44312
|
48323
|
48324
|
50296
|
50297
|
60569
|
60570
|
68187
|
69142
|
69143
|
72105
|
72106
|
72107
|
72108
| 72109 |
72217