Bug 22600: Set 'commandline' interface appropriately
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 28 Mar 2019 14:32:05 +0000 (14:32 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 10 Apr 2019 19:43:11 +0000 (19:43 +0000)
This patch change Koha::Cron to be a more generic Koha::Script class and
update all commanline driven scripts to use it.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

99 files changed:
Koha/Script.pm [moved from Koha/Cron.pm with 52% similarity]
misc/admin/koha-preferences
misc/batchCompareMARCvsFrameworks.pl
misc/batchDeleteUnusedSubfields.pl
misc/batchImportMARCWithBiblionumbers.pl
misc/batchRebuildBiblioTables.pl
misc/batchRebuildItemsTables.pl
misc/batchRepairMissingBiblionumbers.pl
misc/batchdeletebiblios.pl
misc/check_sysprefs.pl
misc/commit_file.pl
misc/cronjobs/advance_notices.pl
misc/cronjobs/automatic_item_modification_by_age.pl
misc/cronjobs/automatic_renewals.pl
misc/cronjobs/batch_anonymise.pl
misc/cronjobs/build_browser_and_cloud.pl
misc/cronjobs/cart_to_shelf.pl
misc/cronjobs/check-url-quick.pl
misc/cronjobs/check-url.pl
misc/cronjobs/cleanup_database.pl
misc/cronjobs/cloud-kw.pl
misc/cronjobs/create_koc_db.pl
misc/cronjobs/delete_expired_opac_registrations.pl
misc/cronjobs/delete_items.pl
misc/cronjobs/delete_patrons.pl
misc/cronjobs/delete_records_via_leader.pl
misc/cronjobs/edi_cron.pl
misc/cronjobs/fines.pl
misc/cronjobs/gather_print_notices.pl
misc/cronjobs/holds/auto_unsuspend_holds.pl
misc/cronjobs/holds/build_holds_queue.pl
misc/cronjobs/holds/cancel_expired_holds.pl
misc/cronjobs/holds/cancel_unfilled_holds.pl
misc/cronjobs/import_webservice_batch.pl
misc/cronjobs/j2a.pl
misc/cronjobs/longoverdue.pl
misc/cronjobs/membership_expiry.pl
misc/cronjobs/merge_authorities.pl
misc/cronjobs/notice_unprocessed_suggestions.pl
misc/cronjobs/overdue_notices.pl
misc/cronjobs/process_message_queue.pl
misc/cronjobs/purge_suggestions.pl
misc/cronjobs/reconcile_balances.pl
misc/cronjobs/remove_temporary_edifiles.pl
misc/cronjobs/rss/rss.pl
misc/cronjobs/runreport.pl
misc/cronjobs/serialsUpdate.pl
misc/cronjobs/share_usage_with_koha_community.pl
misc/cronjobs/sitemap.pl
misc/cronjobs/social_data/get_report_social_data.pl
misc/cronjobs/social_data/update_social_data.pl
misc/cronjobs/staticfines.pl
misc/cronjobs/stockrotation.pl
misc/cronjobs/thirdparty/TalkingTech_itiva_inbound.pl
misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl
misc/cronjobs/update_totalissues.pl
misc/devel/create_superlibrarian.pl
misc/devel/populate_db.pl
misc/export_borrowers.pl
misc/export_records.pl
misc/exportauth.pl
misc/import_patrons.pl
misc/link_bibs_to_authorities.pl
misc/maintenance/UNIMARC_fix_collectiontitle.pl
misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl
misc/maintenance/auth_show_hidden_data.pl
misc/maintenance/borrowers-force-messaging-defaults.pl
misc/maintenance/cmp_sysprefs.pl
misc/maintenance/fix_accountlines_date.pl
misc/maintenance/fix_accountlines_rmdupfines_bug8253.pl
misc/maintenance/fix_mysql_constraints.pl
misc/maintenance/fix_tags_weight.pl
misc/maintenance/make_zebra_dom_cfg_from_record_abs
misc/maintenance/process_record_through_filter.pl
misc/maintenance/remove_items_from_biblioitems.pl
misc/maintenance/sanitize_records.pl
misc/maintenance/search_for_data_inconsistencies.pl
misc/maintenance/touch_all_biblios.pl
misc/maintenance/touch_all_items.pl
misc/maintenance/update_authorities.pl
misc/migration_tools/buildCOUNTRY.pl
misc/migration_tools/buildEDITORS.pl
misc/migration_tools/buildLANG.pl
misc/migration_tools/build_oai_sets.pl
misc/migration_tools/bulkmarcimport.pl
misc/migration_tools/checkNonIndexedBiblios.pl
misc/migration_tools/create_analytical_rel.pl
misc/migration_tools/fix_onloan.pl
misc/migration_tools/import_lexile.pl
misc/migration_tools/rebuild_zebra.pl
misc/migration_tools/remove_unused_authorities.pl
misc/migration_tools/switch_marc21_series_info.pl
misc/migration_tools/upgradeitems.pl
misc/mod_zebraqueue.pl
misc/recreateIssueStatistics.pl
misc/search_tools/rebuild_elastic_search.pl
misc/stage_file.pl
t/Koha/Script.t [copied from t/Koha/Cron.t with 83% similarity]
t/Koha/Script_cron.t [moved from t/Koha/Cron.t with 88% similarity]

similarity index 52%
rename from Koha/Cron.pm
rename to Koha/Script.pm
index 95bd3a9..26efd12 100644 (file)
@@ -1,4 +1,4 @@
-package Koha::Cron;
+package Koha::Script;
 
 # Copyright PTFS Europe 2019
 # Copyright 2019 Koha Development Team
@@ -22,29 +22,50 @@ use Modern::Perl;
 
 =head1 NAME
 
-Koha::Cron - Koha Cron scripts base class
+Koha::Script - Koha scripts base class
 
 =head1 SYNOPSIS
 
-    use Koha::Cron;
+    use Koha::Script
+    use Koha::Script -cron;
 
 =head1 DESCRIPTION
 
-This class should be used in all cronscripts. It sets the interface and userenv appropriately.
+This class should be used in all scripts. It sets the interface and userenv appropriately.
 
 =cut
 
 use C4::Context;
 
-# Set userenv
-C4::Context->_new_userenv(1);
-C4::Context->set_userenv(
-    undef, undef, undef, 'CRON', 'CRON', undef,
-    undef, undef, undef, undef,  undef
-);
-
-# Set interface
-C4::Context->interface('cron');
+sub import {
+    my $class = shift;
+    my @flags = @_;
+
+    C4::Context->_new_userenv(1);
+    if ( ( $flags[0] || '' ) eq '-cron' ) {
+
+        # Set userenv
+        C4::Context->_new_userenv(1);
+        C4::Context->set_userenv(
+            undef, undef, undef, 'CRON', 'CRON', undef,
+            undef, undef, undef, undef,  undef
+        );
+
+        # Set interface
+        C4::Context->interface('cron');
+
+    }
+    else {
+        # Set userenv
+        C4::Context->set_userenv(
+            undef, undef, undef, 'CLI', 'CLI', undef,
+            undef, undef, undef, undef,  undef
+        );
+
+        # Set interface
+        C4::Context->interface('commandline');
+    }
+}
 
 =head1 AUTHOR
 
index 15b7939..34e34b8 100755 (executable)
@@ -18,6 +18,7 @@
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 #
 
+use Koha::Script;
 use C4::Boolean;
 use C4::Context;
 use C4::Debug;
index 9bbcde4..af8a667 100755 (executable)
@@ -12,6 +12,7 @@ BEGIN {
 }
 
 # Koha modules used
+use Koha::Script;
 use C4::Context;
 use MARC::File::USMARC;
 use MARC::Record;
index a1c5093..a80d4fd 100755 (executable)
@@ -11,6 +11,7 @@ BEGIN {
 }
 
 # Koha modules used
+use Koha::Script;
 use MARC::Record;
 use C4::Context;
 use C4::Biblio;
index 24692fd..36781c2 100755 (executable)
@@ -12,6 +12,7 @@ BEGIN {
 
 # Koha modules used
 
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use MARC::Record;
index 5db801b..f9bd218 100755 (executable)
@@ -13,6 +13,7 @@ BEGIN {
 }
 
 # Koha modules used
+use Koha::Script;
 use MARC::Record;
 use C4::Context;
 use C4::Biblio;
index 0e611dd..f1e1300 100755 (executable)
@@ -8,6 +8,7 @@ use MARC::Record;
 use Pod::Usage;
 use Time::HiRes qw(gettimeofday);
 
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use C4::Items;
index ca8064c..695c452 100755 (executable)
@@ -12,7 +12,7 @@ BEGIN {
 }
 
 # Koha modules used
-
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 
index 9bc999a..bcfd74e 100755 (executable)
@@ -5,6 +5,7 @@ use Getopt::Long;
 use Pod::Usage;
 use IO::File;
 
+use Koha::Script;
 use C4::Biblio;
 
 my ($help, $files);
index d69ee15..ce2e19e 100755 (executable)
@@ -10,6 +10,7 @@ use warnings;
 
 use File::Find;
 
+use Koha::Script;
 use C4::Context;
 
 @ARGV = qw(.) unless @ARGV;
index bd29df3..bb7dd03 100755 (executable)
@@ -9,6 +9,7 @@ BEGIN {
     eval { require "$FindBin::Bin/kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Context;
 use C4::ImportBatch;
 use Getopt::Long;
index eeb0d7e..f0f1425 100755 (executable)
@@ -49,7 +49,7 @@ BEGIN {
     use FindBin;
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Biblio;
 use C4::Context;
 use C4::Letters;
index 6f04e54..364f61f 100755 (executable)
@@ -6,7 +6,7 @@ use Getopt::Long;
 use Pod::Usage;
 use JSON;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Items;
 
index 32017c9..8162472 100755 (executable)
@@ -52,7 +52,7 @@ use Modern::Perl;
 use Pod::Usage;
 use Getopt::Long;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Circulation;
 use C4::Context;
 use C4::Log;
index 654f61c..ea63dfa 100755 (executable)
@@ -29,7 +29,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use Koha::Patrons;
 use Date::Calc qw(
index a72c1f9..d180bcb 100755 (executable)
@@ -10,7 +10,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Koha;
 use C4::Context;
 use C4::Biblio;
index 0e35c96..414f6e3 100755 (executable)
@@ -28,7 +28,7 @@ cart_to_shelf.pl  cron script to set items with location of CART to original she
 use strict;
 use warnings;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Items qw/ CartToShelf /;
 use C4::Log;
 
index 5b596f0..93fcd97 100755 (executable)
@@ -21,7 +21,7 @@ use Modern::Perl;
 use Pod::Usage;
 use Getopt::Long;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Biblio;
 use AnyEvent;
index dc916c4..68a7b8e 100755 (executable)
@@ -78,7 +78,7 @@ use strict;
 use warnings;
 use LWP::UserAgent;
 use HTTP::Request;
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Biblio;
 
 
@@ -148,7 +148,7 @@ use Carp;
 
 use Pod::Usage;
 use Getopt::Long;
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 
 
index bc2404f..6ddb1ba 100755 (executable)
@@ -34,7 +34,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Search;
 use C4::Search::History;
index 4432183..46a972e 100755 (executable)
@@ -26,7 +26,7 @@ use YAML::Syck;
 use Pod::Usage;
 use Getopt::Long;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Log;
 
index d6d158e..3d92fe5 100755 (executable)
@@ -95,7 +95,7 @@ use DBI;
 use Getopt::Long;
 use Pod::Usage;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use English qw(-no_match_vars);
 
index 47950b4..28dd3c7 100755 (executable)
@@ -28,7 +28,7 @@ BEGIN {
     eval { my $lib = "$FindBin::Bin/../kohalib.pl"; require $lib };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 
 my $help;
index bccc0e0..6c2962a 100755 (executable)
@@ -2,7 +2,7 @@
 
 use Getopt::Long;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Items;
 use C4::Circulation;
index 5f67213..e8e90dd 100755 (executable)
@@ -5,7 +5,7 @@ use Modern::Perl;
 use Pod::Usage;
 use Getopt::Long;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Members;
 use Koha::DateUtils;
 use Koha::Patrons;
index 11dc33d..80c9996 100755 (executable)
@@ -33,7 +33,7 @@ BEGIN {
 
 use Getopt::Long;
 use Pod::Usage;
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Biblio;
 use C4::Items;
 use Koha::Database;
index dfc1a2e..b345dc4 100755 (executable)
@@ -29,7 +29,7 @@ use utf8;
 # can be run as frequently as required
 # log messages are appended to logdir/editrace.log
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use Log::Log4perl qw(:easy);
 use Koha::Database;
index ac74adc..f04da4b 100755 (executable)
@@ -30,7 +30,7 @@ use strict;
 use warnings;
 use 5.010;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Overdues;
 use Getopt::Long;
index a0c85c8..6b64a76 100755 (executable)
@@ -10,7 +10,7 @@ BEGIN {
 }
 
 use CGI qw( utf8 ); # NOT a CGI script, this is just to keep C4::Templates::gettemplate happy
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Debug;
 use C4::Letters;
index 83d5d60..eb4fd87 100755 (executable)
@@ -29,7 +29,7 @@ BEGIN {
 
 # cancel all expired hold requests
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Reserves;
 use C4::Log;
 
index 370a9da..ab138f9 100755 (executable)
@@ -15,7 +15,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::HoldsQueue qw(CreateQueue);
 use C4::Log;
 
index 6de289b..9ef50de 100755 (executable)
@@ -29,7 +29,7 @@ BEGIN {
 
 # cancel all expired hold requests
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Reserves;
 use C4::Log;
 
index 0cae7fb..ba6a400 100755 (executable)
@@ -28,7 +28,7 @@ BEGIN {
 use Getopt::Long;
 use Pod::Usage;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Reserves;
 use C4::Log;
 use Koha::Holds;
index 55de9be..aa18edc 100755 (executable)
@@ -31,7 +31,7 @@ BEGIN {
 
 use Getopt::Long;
 use Pod::Usage;
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::ImportBatch;
 
 my ($help, $framework);
index 4fb22fa..cdbb8f8 100755 (executable)
@@ -26,7 +26,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Members;
 use Getopt::Long;
index 82d13b1..e1e91b6 100755 (executable)
@@ -34,7 +34,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Items;
 use C4::Circulation qw/LostItem MarkIssueReturned/;
index 3ce0537..5038ce1 100755 (executable)
@@ -126,7 +126,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Letters;
 use C4::Log;
index c2ef914..727d7d5 100755 (executable)
@@ -5,7 +5,7 @@ use Getopt::Long;
 use Pod::Usage;
 use Time::HiRes qw(gettimeofday);
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::AuthoritiesMarc;
 use Koha::Authority::MergeRequests;
 
index fa79e89..55205a1 100755 (executable)
@@ -5,7 +5,7 @@ use Modern::Perl;
 use Pod::Usage;
 use Getopt::Long;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Budgets qw( GetBudget );
 use C4::Suggestions qw( GetUnprocessedSuggestions );
 use Koha::Libraries;
index 8c8f6a0..1f9015a 100755 (executable)
@@ -34,7 +34,7 @@ use Text::CSV_XS;
 use DateTime;
 use DateTime::Duration;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Letters;
 use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes parse_overdues_letter);
index c78d4c0..0532a5b 100755 (executable)
@@ -26,7 +26,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Letters;
 use C4::Log;
 use Getopt::Long;
index 5553657..9fdc26d 100755 (executable)
@@ -29,7 +29,7 @@ BEGIN {
 use Getopt::Long;
 use Pod::Usage;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Suggestions;
 use C4::Log;
 use C4::Context;
index 8ff7e85..0dcae6c 100755 (executable)
@@ -62,7 +62,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Log;
 
 use Koha::Account::Lines;
index a38c911..7791717 100755 (executable)
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 
 # this script will remove those older than 5 days
index f9c5125..9b12372 100755 (executable)
@@ -29,7 +29,7 @@ use Modern::Perl;
 
 use Template;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use Time::Local;
 use POSIX;
index a673a5b..b62639b 100755 (executable)
@@ -20,7 +20,7 @@
 
 use Modern::Perl;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Reports::Guided; # 0.12
 use Koha::Reports;
 use C4::Context;
index 6bf40c1..d69cf0f 100755 (executable)
@@ -28,7 +28,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Debug;
 use C4::Serials;
index 3173ab4..3484df3 100755 (executable)
@@ -5,7 +5,7 @@ use Modern::Perl;
 use Pod::Usage;
 use Getopt::Long;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::UsageStats;
 use C4::Log;
index 909ad6f..093afb1 100755 (executable)
@@ -24,7 +24,7 @@ use utf8;
 use Pod::Usage;
 use Getopt::Long;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Biblio;
 use Koha::Sitemapper;
 
index 5bb9867..c5e13aa 100755 (executable)
@@ -2,7 +2,7 @@
 
 use Modern::Perl;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::SocialData;
 
 my $results = C4::SocialData::get_report;
index 81bc1d0..58e3dc0 100755 (executable)
@@ -2,7 +2,7 @@
 
 use Modern::Perl;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::SocialData;
 
index 1d4c2dc..2a98fea 100755 (executable)
@@ -37,7 +37,7 @@ BEGIN {
 
 use Date::Calc qw/Date_to_Days/;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Circulation;
 use C4::Overdues;
index d178ed8..69ae97e 100755 (executable)
@@ -110,7 +110,7 @@ database updates have been performed.").
 use Modern::Perl;
 use Getopt::Long qw/HelpMessage :config gnu_getopt/;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Letters;
 use Koha::StockRotationRotas;
index abf81cb..5584ddd 100755 (executable)
@@ -31,7 +31,7 @@ BEGIN {
 use Getopt::Long;
 use Pod::Usage;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 
 sub usage {
index 216f39d..98a3d10 100755 (executable)
@@ -31,7 +31,7 @@ BEGIN {
 use Getopt::Long;
 use Pod::Usage;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Items;
 use C4::Letters;
index 667b5ac..eb11861 100755 (executable)
@@ -31,7 +31,7 @@ BEGIN {
 use Getopt::Long;
 use Pod::Usage;
 
-use Koha::Cron;
+use Koha::Script -cron;
 use C4::Context;
 use C4::Biblio;
 use C4::Log;
index f17b1f5..28c67b6 100755 (executable)
@@ -21,6 +21,7 @@ use Modern::Perl;
 use Getopt::Long;
 use Pod::Usage;
 
+use Koha::Script;
 use Koha::Patrons;
 
 my ( $help, $surname, $userid, $password, $branchcode, $categorycode, $cardnumber );
index e419e37..f2cb974 100755 (executable)
@@ -22,6 +22,7 @@ use Modern::Perl;
 use Getopt::Long;
 use Pod::Usage;
 
+use Koha::Script;
 use C4::Installer;
 use C4::Context;
 
index 5f5c7f7..4733c3c 100755 (executable)
@@ -23,6 +23,7 @@ use Modern::Perl;
 use Text::CSV;
 use Getopt::Long qw(:config no_ignore_case);
 
+use Koha::Script;
 use C4::Context;
 use Koha::Patrons;
 
index a1eecc8..b5a7291 100755 (executable)
@@ -22,6 +22,7 @@ use List::MoreUtils qw(uniq);
 use Getopt::Long;
 use Pod::Usage;
 
+use Koha::Script;
 use C4::Auth;
 use C4::Context;
 use C4::Record;
index d6236d2..2f5e3dd 100755 (executable)
@@ -12,6 +12,7 @@ BEGIN {
     eval { require "$FindBin::Bin/kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use C4::Auth;
index 8f639a5..f840601 100755 (executable)
@@ -22,6 +22,7 @@ use Modern::Perl;
 use Getopt::Long;
 use Pod::Usage;
 
+use Koha::Script;
 use Koha::Patrons::Import;
 my $Import = Koha::Patrons::Import->new();
 
index 2711d16..699451a 100755 (executable)
@@ -11,6 +11,7 @@ BEGIN {
     eval { require "$FindBin::Bin/kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use Getopt::Long;
index d977222..4a97c18 100755 (executable)
@@ -12,6 +12,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Biblio;
 
 sub process {
index a46dc7b..e3db4d4 100755 (executable)
@@ -12,6 +12,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Biblio;
 use Getopt::Long;
 
index 7f17945..91006d1 100755 (executable)
@@ -25,6 +25,7 @@ use Modern::Perl;
 use Getopt::Long;
 use Pod::Usage;
 
+use Koha::Script;
 use Koha::Authorities;
 use Koha::Authority::Subfields;
 use Koha::MetadataRecord::Authority;
index d88d387..c446ca0 100755 (executable)
@@ -26,6 +26,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Context;
 use C4::Members::Messaging;
 use Getopt::Long;
index 936d3c6..250333f 100755 (executable)
@@ -30,6 +30,7 @@ use open OUT => ':encoding(UTF-8)', ':std';
 use Getopt::Long;
 use Pod::Usage;
 
+use Koha::Script;
 use C4::Context;
 my $dbh = C4::Context->dbh;
 
index 30479f4..0c7a92e 100755 (executable)
@@ -26,6 +26,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Context;
 use Getopt::Long;
 use Pod::Usage;
index 96ec288..c73ae8d 100755 (executable)
@@ -27,6 +27,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Context;
 use C4::Installer;
 
index 0147224..00588b7 100755 (executable)
@@ -30,6 +30,7 @@ use Getopt::Long;
 use Pod::Usage;
 use YAML;
 use Try::Tiny;
+use Koha::Script;
 use C4::Context;
 
 
index 7dc3801..a1f8085 100755 (executable)
@@ -22,6 +22,7 @@ use Modern::Perl;
 use C4::Context;
 use C4::Tags;
 
+use Koha::Script;
 use Koha::Database;
 use Koha::Tags;
 use Koha::Tags::Approvals;
index 3518e65..d62b978 100755 (executable)
@@ -20,6 +20,7 @@ use strict;
 use warnings;
 use 5.010;
 
+use Koha::Script;
 use Koha::Indexer::Utils;
 
 use Getopt::Long;
index baf137a..a9d92d3 100755 (executable)
@@ -6,6 +6,8 @@
 
 use strict;
 use warnings;
+
+use Koha::Script;
 use Koha::RecordProcessor;
 use Data::Dumper;
 use C4::Biblio;
index 597195e..d78ad69 100755 (executable)
@@ -22,6 +22,7 @@ use strict;
 use warnings;
 $|=1;
 
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use Getopt::Long;
index 2c8000c..b2547cc 100755 (executable)
@@ -18,6 +18,8 @@
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
+
+use Koha::Script;
 use C4::Charset qw( SanitizeRecord );
 use C4::Context;
 use DBI;
index 525d8c7..fa5aa20 100755 (executable)
@@ -17,6 +17,7 @@
 
 use Modern::Perl;
 
+use Koha::Script;
 use Koha::Items;
 use Koha::Biblioitems;
 use Koha::ItemTypes;
index b6a5add..f0630b7 100755 (executable)
@@ -28,6 +28,8 @@ BEGIN {
 
 # possible modules to use
 use Getopt::Long;
+
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use Pod::Usage;
index 12dca00..9b3093a 100755 (executable)
@@ -28,6 +28,8 @@ BEGIN {
 
 # possible modules to use
 use Getopt::Long;
+
+use Koha::Script;
 use C4::Context;
 use C4::Items;
 use Pod::Usage;
index 97b6cc3..a854f5a 100755 (executable)
@@ -23,6 +23,7 @@ use Getopt::Long;
 use List::MoreUtils qw/uniq/;
 use Pod::Usage;
 
+use Koha::Script;
 use C4::AuthoritiesMarc qw/AddAuthority DelAuthority GetAuthority merge/;
 
 my ( @authid, $confirm, $delete, $help, $merge, $reference, $renumber, $verbose );
index 5cd2da4..daca8e5 100755 (executable)
@@ -6,6 +6,7 @@ use strict;
 #use warnings; FIXME - Bug 2505
 
 # Koha modules used
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use C4::AuthoritiesMarc;
index f5e1a71..37ece96 100755 (executable)
@@ -8,6 +8,7 @@ use strict;
 use MARC::File::USMARC;
 use MARC::Record;
 use MARC::Batch;
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use C4::AuthoritiesMarc;
index 18c27ac..5e0a5ab 100755 (executable)
@@ -6,6 +6,7 @@ use strict;
 #use warnings; FIXME - Bug 2505
 
 # Koha modules used
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use C4::AuthoritiesMarc;
index 40dfa1b..a19cc4c 100755 (executable)
@@ -42,6 +42,7 @@ use MARC::File::XML;
 use List::MoreUtils qw/uniq/;
 use Getopt::Std;
 
+use Koha::Script;
 use C4::Context;
 use C4::Charset qw/StripNonXmlChars/;
 use C4::Biblio;
index bd80a69..5e03ca1 100755 (executable)
@@ -17,6 +17,7 @@ use MARC::Record;
 use MARC::Batch;
 use MARC::Charset;
 
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use C4::Koha;
index bd47431..d03acbf 100755 (executable)
@@ -33,6 +33,7 @@ BEGIN {
 
 # Koha modules used
 use MARC::Record;
+use Koha::Script;
 use C4::Context;
 use Getopt::Long;
 
index a06305f..2de9c23 100755 (executable)
@@ -9,6 +9,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use C4::Items;
index d6e63af..d70c3a5 100755 (executable)
@@ -2,7 +2,9 @@
 
 use strict;
 #use warnings; FIXME - Bug 2505
-use  C4::Context;
+
+use Koha::Script;
+use C4::Context;
 use C4::Items;
 use C4::Biblio;
 
index 131db44..520c357 100755 (executable)
@@ -31,6 +31,7 @@ use Modern::Perl;
 use Getopt::Long;
 use Text::CSV;
 
+use Koha::Script;
 use C4::Context;
 use C4::Biblio;
 use C4::Koha qw( GetVariationsOfISBN );
index a79e7a8..65ccff5 100755 (executable)
@@ -17,6 +17,7 @@
 
 use Modern::Perl;
 
+use Koha::Script;
 use C4::Context;
 use Getopt::Long;
 use Fcntl qw(:flock);
index f4e0ecb..bef6cbe 100755 (executable)
@@ -23,6 +23,7 @@
 use strict;
 use warnings;
 
+use Koha::Script;
 use C4::Context;
 use C4::AuthoritiesMarc;
 use Getopt::Long;
index 54823de..0bad3f2 100755 (executable)
@@ -29,6 +29,7 @@ BEGIN {
     eval { require "$FindBin::Bin/../kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Biblio;
 use C4::Context;
 use Getopt::Long;
index e3f11d6..cc63cd4 100755 (executable)
@@ -2,7 +2,9 @@
 
 use strict;
 #use warnings; FIXME - Bug 2505
-use  C4::Context;
+
+use Koha::Script;
+use C4::Context;
 use C4::Items;
 use C4::Biblio;
 
index 32fcc31..240aad4 100755 (executable)
@@ -23,6 +23,7 @@ use Modern::Perl;
 use Getopt::Long;
 use Pod::Usage;
 
+use Koha::Script;
 use C4::Biblio;
 
 my @biblios;
index 6ba83e1..2cafb4f 100755 (executable)
@@ -22,6 +22,8 @@
 
 use strict;
 use warnings;
+
+use Koha::Script;
 use C4::Context;
 use C4::Items;
 use Data::Dumper;
index caa9a3d..a233cf5 100755 (executable)
@@ -83,6 +83,7 @@ Full documentation.
 
 use autodie;
 use Getopt::Long;
+use Koha::Script;
 use C4::Context;
 use Koha::MetadataRecord::Authority;
 use Koha::BiblioUtils;
index b86f525..b856e3e 100755 (executable)
@@ -27,6 +27,7 @@ BEGIN {
     eval { require "$FindBin::Bin/kohalib.pl" };
 }
 
+use Koha::Script;
 use C4::Context;
 use C4::ImportBatch;
 use C4::Matcher;
similarity index 83%
copy from t/Koha/Cron.t
copy to t/Koha/Script.t
index 05ecd25..7c758f4 100644 (file)
@@ -19,7 +19,7 @@ use Modern::Perl;
 
 use Test::More tests => 3;
 
-BEGIN { use_ok('Koha::Cron') }
+BEGIN { use_ok('Koha::Script') }
 
 use C4::Context;
 
@@ -27,11 +27,11 @@ my $userenv = C4::Context->userenv;
 is_deeply(
     $userenv,
     {
-        'surname'       => 'CRON',
+        'surname'       => 'CLI',
         'id'            => undef,
         'flags'         => undef,
         'cardnumber'    => undef,
-        'firstname'     => 'CRON',
+        'firstname'     => 'CLI',
         'branchname'    => undef,
         'branchprinter' => undef,
         'emailaddress'  => undef,
@@ -39,10 +39,10 @@ is_deeply(
         'shibboleth'    => undef,
         'branch'        => undef
     },
-    "Context userenv set correctly"
+    "Context userenv set correctly with no flags"
 );
 
 my $interface = C4::Context->interface;
-is($interface, 'cron', "Context interface set correctly");
+is( $interface, 'commandline', "Context interface set correctly with no flags" );
 
 1;
similarity index 88%
rename from t/Koha/Cron.t
rename to t/Koha/Script_cron.t
index 05ecd25..d73aa82 100644 (file)
@@ -19,7 +19,7 @@ use Modern::Perl;
 
 use Test::More tests => 3;
 
-BEGIN { use_ok('Koha::Cron') }
+BEGIN { use_ok( "Koha::Script", '-cron' ) }
 
 use C4::Context;
 
@@ -39,10 +39,10 @@ is_deeply(
         'shibboleth'    => undef,
         'branch'        => undef
     },
-    "Context userenv set correctly"
+    "Context userenv set correctly with -cron"
 );
 
 my $interface = C4::Context->interface;
-is($interface, 'cron', "Context interface set correctly");
+is( $interface, 'cron', "Context interface set correctly with -cron" );
 
 1;