From d2e189ca1c4f11d12435008053336563af2dd911 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 28 Mar 2019 14:32:05 +0000 Subject: [PATCH] Bug 22600: Set 'commandline' interface appropriately 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 Signed-off-by: Josef Moravec Signed-off-by: Tomas Cohen Arazi Signed-off-by: Nick Clemens --- Koha/{Cron.pm => Script.pm} | 47 +++++++++++++----- misc/admin/koha-preferences | 1 + misc/batchCompareMARCvsFrameworks.pl | 1 + misc/batchDeleteUnusedSubfields.pl | 1 + misc/batchImportMARCWithBiblionumbers.pl | 1 + misc/batchRebuildBiblioTables.pl | 1 + misc/batchRebuildItemsTables.pl | 1 + misc/batchRepairMissingBiblionumbers.pl | 2 +- misc/batchdeletebiblios.pl | 1 + misc/check_sysprefs.pl | 1 + misc/commit_file.pl | 1 + misc/cronjobs/advance_notices.pl | 2 +- .../automatic_item_modification_by_age.pl | 2 +- misc/cronjobs/automatic_renewals.pl | 2 +- misc/cronjobs/batch_anonymise.pl | 2 +- misc/cronjobs/build_browser_and_cloud.pl | 2 +- misc/cronjobs/cart_to_shelf.pl | 2 +- misc/cronjobs/check-url-quick.pl | 2 +- misc/cronjobs/check-url.pl | 4 +- misc/cronjobs/cleanup_database.pl | 2 +- misc/cronjobs/cloud-kw.pl | 2 +- misc/cronjobs/create_koc_db.pl | 2 +- .../delete_expired_opac_registrations.pl | 2 +- misc/cronjobs/delete_items.pl | 2 +- misc/cronjobs/delete_patrons.pl | 2 +- misc/cronjobs/delete_records_via_leader.pl | 2 +- misc/cronjobs/edi_cron.pl | 2 +- misc/cronjobs/fines.pl | 2 +- misc/cronjobs/gather_print_notices.pl | 2 +- misc/cronjobs/holds/auto_unsuspend_holds.pl | 2 +- misc/cronjobs/holds/build_holds_queue.pl | 2 +- misc/cronjobs/holds/cancel_expired_holds.pl | 2 +- misc/cronjobs/holds/cancel_unfilled_holds.pl | 2 +- misc/cronjobs/import_webservice_batch.pl | 2 +- misc/cronjobs/j2a.pl | 2 +- misc/cronjobs/longoverdue.pl | 2 +- misc/cronjobs/membership_expiry.pl | 2 +- misc/cronjobs/merge_authorities.pl | 2 +- .../notice_unprocessed_suggestions.pl | 2 +- misc/cronjobs/overdue_notices.pl | 2 +- misc/cronjobs/process_message_queue.pl | 2 +- misc/cronjobs/purge_suggestions.pl | 2 +- misc/cronjobs/reconcile_balances.pl | 2 +- misc/cronjobs/remove_temporary_edifiles.pl | 2 +- misc/cronjobs/rss/rss.pl | 2 +- misc/cronjobs/runreport.pl | 2 +- misc/cronjobs/serialsUpdate.pl | 2 +- .../share_usage_with_koha_community.pl | 2 +- misc/cronjobs/sitemap.pl | 2 +- .../social_data/get_report_social_data.pl | 2 +- .../social_data/update_social_data.pl | 2 +- misc/cronjobs/staticfines.pl | 2 +- misc/cronjobs/stockrotation.pl | 2 +- .../thirdparty/TalkingTech_itiva_inbound.pl | 2 +- .../thirdparty/TalkingTech_itiva_outbound.pl | 2 +- misc/cronjobs/update_totalissues.pl | 2 +- misc/devel/create_superlibrarian.pl | 1 + misc/devel/populate_db.pl | 1 + misc/export_borrowers.pl | 1 + misc/export_records.pl | 1 + misc/exportauth.pl | 1 + misc/import_patrons.pl | 1 + misc/link_bibs_to_authorities.pl | 1 + .../UNIMARC_fix_collectiontitle.pl | 1 + ...MARC_sync_date_created_with_marc_biblio.pl | 1 + misc/maintenance/auth_show_hidden_data.pl | 1 + .../borrowers-force-messaging-defaults.pl | 1 + misc/maintenance/cmp_sysprefs.pl | 1 + misc/maintenance/fix_accountlines_date.pl | 1 + .../fix_accountlines_rmdupfines_bug8253.pl | 1 + misc/maintenance/fix_mysql_constraints.pl | 1 + misc/maintenance/fix_tags_weight.pl | 1 + .../make_zebra_dom_cfg_from_record_abs | 1 + .../process_record_through_filter.pl | 2 + .../remove_items_from_biblioitems.pl | 1 + misc/maintenance/sanitize_records.pl | 2 + .../search_for_data_inconsistencies.pl | 1 + misc/maintenance/touch_all_biblios.pl | 2 + misc/maintenance/touch_all_items.pl | 2 + misc/maintenance/update_authorities.pl | 1 + misc/migration_tools/buildCOUNTRY.pl | 1 + misc/migration_tools/buildEDITORS.pl | 1 + misc/migration_tools/buildLANG.pl | 1 + misc/migration_tools/build_oai_sets.pl | 1 + misc/migration_tools/bulkmarcimport.pl | 1 + .../migration_tools/checkNonIndexedBiblios.pl | 1 + misc/migration_tools/create_analytical_rel.pl | 1 + misc/migration_tools/fix_onloan.pl | 4 +- misc/migration_tools/import_lexile.pl | 1 + misc/migration_tools/rebuild_zebra.pl | 1 + .../remove_unused_authorities.pl | 1 + .../switch_marc21_series_info.pl | 1 + misc/migration_tools/upgradeitems.pl | 4 +- misc/mod_zebraqueue.pl | 1 + misc/recreateIssueStatistics.pl | 2 + misc/search_tools/rebuild_elastic_search.pl | 1 + misc/stage_file.pl | 1 + t/Koha/Script.t | 48 +++++++++++++++++++ t/Koha/{Cron.t => Script_cron.t} | 6 +-- 99 files changed, 191 insertions(+), 65 deletions(-) rename Koha/{Cron.pm => Script.pm} (52%) create mode 100644 t/Koha/Script.t rename t/Koha/{Cron.t => Script_cron.t} (88%) diff --git a/Koha/Cron.pm b/Koha/Script.pm similarity index 52% rename from Koha/Cron.pm rename to Koha/Script.pm index 95bd3a9504..26efd12c8c 100644 --- a/Koha/Cron.pm +++ b/Koha/Script.pm @@ -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 diff --git a/misc/admin/koha-preferences b/misc/admin/koha-preferences index 15b79391b3..34e34b8b56 100755 --- a/misc/admin/koha-preferences +++ b/misc/admin/koha-preferences @@ -18,6 +18,7 @@ # along with Koha; if not, see . # +use Koha::Script; use C4::Boolean; use C4::Context; use C4::Debug; diff --git a/misc/batchCompareMARCvsFrameworks.pl b/misc/batchCompareMARCvsFrameworks.pl index 9bbcde46df..af8a66796e 100755 --- a/misc/batchCompareMARCvsFrameworks.pl +++ b/misc/batchCompareMARCvsFrameworks.pl @@ -12,6 +12,7 @@ BEGIN { } # Koha modules used +use Koha::Script; use C4::Context; use MARC::File::USMARC; use MARC::Record; diff --git a/misc/batchDeleteUnusedSubfields.pl b/misc/batchDeleteUnusedSubfields.pl index a1c509318f..a80d4fdd6f 100755 --- a/misc/batchDeleteUnusedSubfields.pl +++ b/misc/batchDeleteUnusedSubfields.pl @@ -11,6 +11,7 @@ BEGIN { } # Koha modules used +use Koha::Script; use MARC::Record; use C4::Context; use C4::Biblio; diff --git a/misc/batchImportMARCWithBiblionumbers.pl b/misc/batchImportMARCWithBiblionumbers.pl index 24692fda56..36781c201e 100755 --- a/misc/batchImportMARCWithBiblionumbers.pl +++ b/misc/batchImportMARCWithBiblionumbers.pl @@ -12,6 +12,7 @@ BEGIN { # Koha modules used +use Koha::Script; use C4::Context; use C4::Biblio; use MARC::Record; diff --git a/misc/batchRebuildBiblioTables.pl b/misc/batchRebuildBiblioTables.pl index 5db801bbc1..f9bd21800b 100755 --- a/misc/batchRebuildBiblioTables.pl +++ b/misc/batchRebuildBiblioTables.pl @@ -13,6 +13,7 @@ BEGIN { } # Koha modules used +use Koha::Script; use MARC::Record; use C4::Context; use C4::Biblio; diff --git a/misc/batchRebuildItemsTables.pl b/misc/batchRebuildItemsTables.pl index 0e611dd701..f1e13003ed 100755 --- a/misc/batchRebuildItemsTables.pl +++ b/misc/batchRebuildItemsTables.pl @@ -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; diff --git a/misc/batchRepairMissingBiblionumbers.pl b/misc/batchRepairMissingBiblionumbers.pl index ca8064c523..695c45291c 100755 --- a/misc/batchRepairMissingBiblionumbers.pl +++ b/misc/batchRepairMissingBiblionumbers.pl @@ -12,7 +12,7 @@ BEGIN { } # Koha modules used - +use Koha::Script; use C4::Context; use C4::Biblio; diff --git a/misc/batchdeletebiblios.pl b/misc/batchdeletebiblios.pl index 9bc999a489..bcfd74ec1c 100755 --- a/misc/batchdeletebiblios.pl +++ b/misc/batchdeletebiblios.pl @@ -5,6 +5,7 @@ use Getopt::Long; use Pod::Usage; use IO::File; +use Koha::Script; use C4::Biblio; my ($help, $files); diff --git a/misc/check_sysprefs.pl b/misc/check_sysprefs.pl index d69ee15499..ce2e19e455 100755 --- a/misc/check_sysprefs.pl +++ b/misc/check_sysprefs.pl @@ -10,6 +10,7 @@ use warnings; use File::Find; +use Koha::Script; use C4::Context; @ARGV = qw(.) unless @ARGV; diff --git a/misc/commit_file.pl b/misc/commit_file.pl index bd29df3b85..bb7dd037a6 100755 --- a/misc/commit_file.pl +++ b/misc/commit_file.pl @@ -9,6 +9,7 @@ BEGIN { eval { require "$FindBin::Bin/kohalib.pl" }; } +use Koha::Script; use C4::Context; use C4::ImportBatch; use Getopt::Long; diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl index eeb0d7e0a8..f0f1425be9 100755 --- a/misc/cronjobs/advance_notices.pl +++ b/misc/cronjobs/advance_notices.pl @@ -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; diff --git a/misc/cronjobs/automatic_item_modification_by_age.pl b/misc/cronjobs/automatic_item_modification_by_age.pl index 6f04e5418e..364f61f183 100755 --- a/misc/cronjobs/automatic_item_modification_by_age.pl +++ b/misc/cronjobs/automatic_item_modification_by_age.pl @@ -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; diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl index 32017c9895..8162472674 100755 --- a/misc/cronjobs/automatic_renewals.pl +++ b/misc/cronjobs/automatic_renewals.pl @@ -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; diff --git a/misc/cronjobs/batch_anonymise.pl b/misc/cronjobs/batch_anonymise.pl index 654f61cabf..ea63dfa01d 100755 --- a/misc/cronjobs/batch_anonymise.pl +++ b/misc/cronjobs/batch_anonymise.pl @@ -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( diff --git a/misc/cronjobs/build_browser_and_cloud.pl b/misc/cronjobs/build_browser_and_cloud.pl index a72c1f95e2..d180bcbea1 100755 --- a/misc/cronjobs/build_browser_and_cloud.pl +++ b/misc/cronjobs/build_browser_and_cloud.pl @@ -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; diff --git a/misc/cronjobs/cart_to_shelf.pl b/misc/cronjobs/cart_to_shelf.pl index 0e35c96b44..414f6e3720 100755 --- a/misc/cronjobs/cart_to_shelf.pl +++ b/misc/cronjobs/cart_to_shelf.pl @@ -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; diff --git a/misc/cronjobs/check-url-quick.pl b/misc/cronjobs/check-url-quick.pl index 5b596f09df..93fcd97a10 100755 --- a/misc/cronjobs/check-url-quick.pl +++ b/misc/cronjobs/check-url-quick.pl @@ -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; diff --git a/misc/cronjobs/check-url.pl b/misc/cronjobs/check-url.pl index dc916c4857..68a7b8e788 100755 --- a/misc/cronjobs/check-url.pl +++ b/misc/cronjobs/check-url.pl @@ -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; diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index bc2404fb90..6ddb1baa3f 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -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; diff --git a/misc/cronjobs/cloud-kw.pl b/misc/cronjobs/cloud-kw.pl index 443218387b..46a972e719 100755 --- a/misc/cronjobs/cloud-kw.pl +++ b/misc/cronjobs/cloud-kw.pl @@ -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; diff --git a/misc/cronjobs/create_koc_db.pl b/misc/cronjobs/create_koc_db.pl index d6d158e9c8..3d92fe5aa3 100755 --- a/misc/cronjobs/create_koc_db.pl +++ b/misc/cronjobs/create_koc_db.pl @@ -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); diff --git a/misc/cronjobs/delete_expired_opac_registrations.pl b/misc/cronjobs/delete_expired_opac_registrations.pl index 47950b4335..28dd3c7c19 100755 --- a/misc/cronjobs/delete_expired_opac_registrations.pl +++ b/misc/cronjobs/delete_expired_opac_registrations.pl @@ -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; diff --git a/misc/cronjobs/delete_items.pl b/misc/cronjobs/delete_items.pl index bccc0e02ef..6c2962a3af 100755 --- a/misc/cronjobs/delete_items.pl +++ b/misc/cronjobs/delete_items.pl @@ -2,7 +2,7 @@ use Getopt::Long; -use Koha::Cron; +use Koha::Script -cron; use C4::Context; use C4::Items; use C4::Circulation; diff --git a/misc/cronjobs/delete_patrons.pl b/misc/cronjobs/delete_patrons.pl index 5f672133be..e8e90dd00e 100755 --- a/misc/cronjobs/delete_patrons.pl +++ b/misc/cronjobs/delete_patrons.pl @@ -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; diff --git a/misc/cronjobs/delete_records_via_leader.pl b/misc/cronjobs/delete_records_via_leader.pl index 11dc33d4e5..80c9996781 100755 --- a/misc/cronjobs/delete_records_via_leader.pl +++ b/misc/cronjobs/delete_records_via_leader.pl @@ -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; diff --git a/misc/cronjobs/edi_cron.pl b/misc/cronjobs/edi_cron.pl index dfc1a2e11e..b345dc4616 100755 --- a/misc/cronjobs/edi_cron.pl +++ b/misc/cronjobs/edi_cron.pl @@ -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; diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index ac74adc75b..f04da4b280 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -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; diff --git a/misc/cronjobs/gather_print_notices.pl b/misc/cronjobs/gather_print_notices.pl index a0c85c894a..6b64a76f90 100755 --- a/misc/cronjobs/gather_print_notices.pl +++ b/misc/cronjobs/gather_print_notices.pl @@ -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; diff --git a/misc/cronjobs/holds/auto_unsuspend_holds.pl b/misc/cronjobs/holds/auto_unsuspend_holds.pl index 83d5d60012..eb4fd874a7 100755 --- a/misc/cronjobs/holds/auto_unsuspend_holds.pl +++ b/misc/cronjobs/holds/auto_unsuspend_holds.pl @@ -29,7 +29,7 @@ BEGIN { # cancel all expired hold requests -use Koha::Cron; +use Koha::Script -cron; use C4::Reserves; use C4::Log; diff --git a/misc/cronjobs/holds/build_holds_queue.pl b/misc/cronjobs/holds/build_holds_queue.pl index 370a9da49a..ab138f9183 100755 --- a/misc/cronjobs/holds/build_holds_queue.pl +++ b/misc/cronjobs/holds/build_holds_queue.pl @@ -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; diff --git a/misc/cronjobs/holds/cancel_expired_holds.pl b/misc/cronjobs/holds/cancel_expired_holds.pl index 6de289b844..9ef50dee2a 100755 --- a/misc/cronjobs/holds/cancel_expired_holds.pl +++ b/misc/cronjobs/holds/cancel_expired_holds.pl @@ -29,7 +29,7 @@ BEGIN { # cancel all expired hold requests -use Koha::Cron; +use Koha::Script -cron; use C4::Reserves; use C4::Log; diff --git a/misc/cronjobs/holds/cancel_unfilled_holds.pl b/misc/cronjobs/holds/cancel_unfilled_holds.pl index 0cae7fb029..ba6a40098a 100755 --- a/misc/cronjobs/holds/cancel_unfilled_holds.pl +++ b/misc/cronjobs/holds/cancel_unfilled_holds.pl @@ -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; diff --git a/misc/cronjobs/import_webservice_batch.pl b/misc/cronjobs/import_webservice_batch.pl index 55de9be2bb..aa18edce51 100755 --- a/misc/cronjobs/import_webservice_batch.pl +++ b/misc/cronjobs/import_webservice_batch.pl @@ -31,7 +31,7 @@ BEGIN { use Getopt::Long; use Pod::Usage; -use Koha::Cron; +use Koha::Script -cron; use C4::ImportBatch; my ($help, $framework); diff --git a/misc/cronjobs/j2a.pl b/misc/cronjobs/j2a.pl index 4fb22fa05d..cdbb8f81ed 100755 --- a/misc/cronjobs/j2a.pl +++ b/misc/cronjobs/j2a.pl @@ -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; diff --git a/misc/cronjobs/longoverdue.pl b/misc/cronjobs/longoverdue.pl index 82d13b1509..e1e91b65ae 100755 --- a/misc/cronjobs/longoverdue.pl +++ b/misc/cronjobs/longoverdue.pl @@ -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/; diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl index 3ce0537016..5038ce1f9f 100755 --- a/misc/cronjobs/membership_expiry.pl +++ b/misc/cronjobs/membership_expiry.pl @@ -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; diff --git a/misc/cronjobs/merge_authorities.pl b/misc/cronjobs/merge_authorities.pl index c2ef91413b..727d7d5f8c 100755 --- a/misc/cronjobs/merge_authorities.pl +++ b/misc/cronjobs/merge_authorities.pl @@ -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; diff --git a/misc/cronjobs/notice_unprocessed_suggestions.pl b/misc/cronjobs/notice_unprocessed_suggestions.pl index fa79e8999a..55205a10c5 100755 --- a/misc/cronjobs/notice_unprocessed_suggestions.pl +++ b/misc/cronjobs/notice_unprocessed_suggestions.pl @@ -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; diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 8c8f6a03ce..1f9015a622 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -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); diff --git a/misc/cronjobs/process_message_queue.pl b/misc/cronjobs/process_message_queue.pl index c78d4c0892..0532a5b899 100755 --- a/misc/cronjobs/process_message_queue.pl +++ b/misc/cronjobs/process_message_queue.pl @@ -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; diff --git a/misc/cronjobs/purge_suggestions.pl b/misc/cronjobs/purge_suggestions.pl index 55536577da..9fdc26d566 100755 --- a/misc/cronjobs/purge_suggestions.pl +++ b/misc/cronjobs/purge_suggestions.pl @@ -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; diff --git a/misc/cronjobs/reconcile_balances.pl b/misc/cronjobs/reconcile_balances.pl index 8ff7e8597a..0dcae6cb13 100755 --- a/misc/cronjobs/reconcile_balances.pl +++ b/misc/cronjobs/reconcile_balances.pl @@ -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; diff --git a/misc/cronjobs/remove_temporary_edifiles.pl b/misc/cronjobs/remove_temporary_edifiles.pl index a38c911285..7791717e50 100755 --- a/misc/cronjobs/remove_temporary_edifiles.pl +++ b/misc/cronjobs/remove_temporary_edifiles.pl @@ -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 diff --git a/misc/cronjobs/rss/rss.pl b/misc/cronjobs/rss/rss.pl index f9c512543b..9b1237236c 100755 --- a/misc/cronjobs/rss/rss.pl +++ b/misc/cronjobs/rss/rss.pl @@ -29,7 +29,7 @@ use Modern::Perl; use Template; -use Koha::Cron; +use Koha::Script -cron; use C4::Context; use Time::Local; use POSIX; diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl index a673a5bcb0..b62639b7d5 100755 --- a/misc/cronjobs/runreport.pl +++ b/misc/cronjobs/runreport.pl @@ -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; diff --git a/misc/cronjobs/serialsUpdate.pl b/misc/cronjobs/serialsUpdate.pl index 6bf40c1f47..d69cf0f6b4 100755 --- a/misc/cronjobs/serialsUpdate.pl +++ b/misc/cronjobs/serialsUpdate.pl @@ -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; diff --git a/misc/cronjobs/share_usage_with_koha_community.pl b/misc/cronjobs/share_usage_with_koha_community.pl index 3173ab40a8..3484df3af5 100755 --- a/misc/cronjobs/share_usage_with_koha_community.pl +++ b/misc/cronjobs/share_usage_with_koha_community.pl @@ -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; diff --git a/misc/cronjobs/sitemap.pl b/misc/cronjobs/sitemap.pl index 909ad6fed2..093afb1c33 100755 --- a/misc/cronjobs/sitemap.pl +++ b/misc/cronjobs/sitemap.pl @@ -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; diff --git a/misc/cronjobs/social_data/get_report_social_data.pl b/misc/cronjobs/social_data/get_report_social_data.pl index 5bb9867485..c5e13aaf1b 100755 --- a/misc/cronjobs/social_data/get_report_social_data.pl +++ b/misc/cronjobs/social_data/get_report_social_data.pl @@ -2,7 +2,7 @@ use Modern::Perl; -use Koha::Cron; +use Koha::Script -cron; use C4::SocialData; my $results = C4::SocialData::get_report; diff --git a/misc/cronjobs/social_data/update_social_data.pl b/misc/cronjobs/social_data/update_social_data.pl index 81bc1d006d..58e3dc0696 100755 --- a/misc/cronjobs/social_data/update_social_data.pl +++ b/misc/cronjobs/social_data/update_social_data.pl @@ -2,7 +2,7 @@ use Modern::Perl; -use Koha::Cron; +use Koha::Script -cron; use C4::Context; use C4::SocialData; diff --git a/misc/cronjobs/staticfines.pl b/misc/cronjobs/staticfines.pl index 1d4c2dc1d6..2a98fea6ec 100755 --- a/misc/cronjobs/staticfines.pl +++ b/misc/cronjobs/staticfines.pl @@ -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; diff --git a/misc/cronjobs/stockrotation.pl b/misc/cronjobs/stockrotation.pl index d178ed8204..69ae97e38f 100755 --- a/misc/cronjobs/stockrotation.pl +++ b/misc/cronjobs/stockrotation.pl @@ -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; diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_inbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_inbound.pl index abf81cb8c5..5584ddd675 100755 --- a/misc/cronjobs/thirdparty/TalkingTech_itiva_inbound.pl +++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_inbound.pl @@ -31,7 +31,7 @@ BEGIN { use Getopt::Long; use Pod::Usage; -use Koha::Cron; +use Koha::Script -cron; use C4::Context; sub usage { diff --git a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl index 216f39d543..98a3d1007f 100755 --- a/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl +++ b/misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl @@ -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; diff --git a/misc/cronjobs/update_totalissues.pl b/misc/cronjobs/update_totalissues.pl index 667b5ac8e0..eb11861f8d 100755 --- a/misc/cronjobs/update_totalissues.pl +++ b/misc/cronjobs/update_totalissues.pl @@ -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; diff --git a/misc/devel/create_superlibrarian.pl b/misc/devel/create_superlibrarian.pl index f17b1f5c59..28c67b66d8 100755 --- a/misc/devel/create_superlibrarian.pl +++ b/misc/devel/create_superlibrarian.pl @@ -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 ); diff --git a/misc/devel/populate_db.pl b/misc/devel/populate_db.pl index e419e3743b..f2cb974655 100755 --- a/misc/devel/populate_db.pl +++ b/misc/devel/populate_db.pl @@ -22,6 +22,7 @@ use Modern::Perl; use Getopt::Long; use Pod::Usage; +use Koha::Script; use C4::Installer; use C4::Context; diff --git a/misc/export_borrowers.pl b/misc/export_borrowers.pl index 5f5c7f74ed..4733c3cbc1 100755 --- a/misc/export_borrowers.pl +++ b/misc/export_borrowers.pl @@ -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; diff --git a/misc/export_records.pl b/misc/export_records.pl index a1eecc8eb2..b5a7291492 100755 --- a/misc/export_records.pl +++ b/misc/export_records.pl @@ -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; diff --git a/misc/exportauth.pl b/misc/exportauth.pl index d6236d21a9..2f5e3dd710 100755 --- a/misc/exportauth.pl +++ b/misc/exportauth.pl @@ -12,6 +12,7 @@ BEGIN { eval { require "$FindBin::Bin/kohalib.pl" }; } +use Koha::Script; use C4::Context; use C4::Biblio; use C4::Auth; diff --git a/misc/import_patrons.pl b/misc/import_patrons.pl index 8f639a5a3b..f8406016d5 100755 --- a/misc/import_patrons.pl +++ b/misc/import_patrons.pl @@ -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(); diff --git a/misc/link_bibs_to_authorities.pl b/misc/link_bibs_to_authorities.pl index 2711d16537..699451a8aa 100755 --- a/misc/link_bibs_to_authorities.pl +++ b/misc/link_bibs_to_authorities.pl @@ -11,6 +11,7 @@ BEGIN { eval { require "$FindBin::Bin/kohalib.pl" }; } +use Koha::Script; use C4::Context; use C4::Biblio; use Getopt::Long; diff --git a/misc/maintenance/UNIMARC_fix_collectiontitle.pl b/misc/maintenance/UNIMARC_fix_collectiontitle.pl index d97722272b..4a97c18e56 100755 --- a/misc/maintenance/UNIMARC_fix_collectiontitle.pl +++ b/misc/maintenance/UNIMARC_fix_collectiontitle.pl @@ -12,6 +12,7 @@ BEGIN { eval { require "$FindBin::Bin/../kohalib.pl" }; } +use Koha::Script; use C4::Biblio; sub process { diff --git a/misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl b/misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl index a46dc7b0f4..e3db4d49fe 100755 --- a/misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl +++ b/misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl @@ -12,6 +12,7 @@ BEGIN { eval { require "$FindBin::Bin/../kohalib.pl" }; } +use Koha::Script; use C4::Biblio; use Getopt::Long; diff --git a/misc/maintenance/auth_show_hidden_data.pl b/misc/maintenance/auth_show_hidden_data.pl index 7f179450d3..91006d1761 100755 --- a/misc/maintenance/auth_show_hidden_data.pl +++ b/misc/maintenance/auth_show_hidden_data.pl @@ -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; diff --git a/misc/maintenance/borrowers-force-messaging-defaults.pl b/misc/maintenance/borrowers-force-messaging-defaults.pl index d88d3870e2..c446ca0f1c 100755 --- a/misc/maintenance/borrowers-force-messaging-defaults.pl +++ b/misc/maintenance/borrowers-force-messaging-defaults.pl @@ -26,6 +26,7 @@ BEGIN { eval { require "$FindBin::Bin/../kohalib.pl" }; } +use Koha::Script; use C4::Context; use C4::Members::Messaging; use Getopt::Long; diff --git a/misc/maintenance/cmp_sysprefs.pl b/misc/maintenance/cmp_sysprefs.pl index 936d3c63f6..250333f0e3 100755 --- a/misc/maintenance/cmp_sysprefs.pl +++ b/misc/maintenance/cmp_sysprefs.pl @@ -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; diff --git a/misc/maintenance/fix_accountlines_date.pl b/misc/maintenance/fix_accountlines_date.pl index 30479f469a..0c7a92e178 100755 --- a/misc/maintenance/fix_accountlines_date.pl +++ b/misc/maintenance/fix_accountlines_date.pl @@ -26,6 +26,7 @@ BEGIN { eval { require "$FindBin::Bin/../kohalib.pl" }; } +use Koha::Script; use C4::Context; use Getopt::Long; use Pod::Usage; diff --git a/misc/maintenance/fix_accountlines_rmdupfines_bug8253.pl b/misc/maintenance/fix_accountlines_rmdupfines_bug8253.pl index 96ec288961..c73ae8d343 100755 --- a/misc/maintenance/fix_accountlines_rmdupfines_bug8253.pl +++ b/misc/maintenance/fix_accountlines_rmdupfines_bug8253.pl @@ -27,6 +27,7 @@ BEGIN { eval { require "$FindBin::Bin/../kohalib.pl" }; } +use Koha::Script; use C4::Context; use C4::Installer; diff --git a/misc/maintenance/fix_mysql_constraints.pl b/misc/maintenance/fix_mysql_constraints.pl index 01472242d8..00588b79f4 100755 --- a/misc/maintenance/fix_mysql_constraints.pl +++ b/misc/maintenance/fix_mysql_constraints.pl @@ -30,6 +30,7 @@ use Getopt::Long; use Pod::Usage; use YAML; use Try::Tiny; +use Koha::Script; use C4::Context; diff --git a/misc/maintenance/fix_tags_weight.pl b/misc/maintenance/fix_tags_weight.pl index 7dc3801c16..a1f8085edd 100755 --- a/misc/maintenance/fix_tags_weight.pl +++ b/misc/maintenance/fix_tags_weight.pl @@ -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; diff --git a/misc/maintenance/make_zebra_dom_cfg_from_record_abs b/misc/maintenance/make_zebra_dom_cfg_from_record_abs index 3518e653d2..d62b978f8d 100755 --- a/misc/maintenance/make_zebra_dom_cfg_from_record_abs +++ b/misc/maintenance/make_zebra_dom_cfg_from_record_abs @@ -20,6 +20,7 @@ use strict; use warnings; use 5.010; +use Koha::Script; use Koha::Indexer::Utils; use Getopt::Long; diff --git a/misc/maintenance/process_record_through_filter.pl b/misc/maintenance/process_record_through_filter.pl index baf137aeb6..a9d92d33ad 100755 --- a/misc/maintenance/process_record_through_filter.pl +++ b/misc/maintenance/process_record_through_filter.pl @@ -6,6 +6,8 @@ use strict; use warnings; + +use Koha::Script; use Koha::RecordProcessor; use Data::Dumper; use C4::Biblio; diff --git a/misc/maintenance/remove_items_from_biblioitems.pl b/misc/maintenance/remove_items_from_biblioitems.pl index 597195eba7..d78ad696ad 100755 --- a/misc/maintenance/remove_items_from_biblioitems.pl +++ b/misc/maintenance/remove_items_from_biblioitems.pl @@ -22,6 +22,7 @@ use strict; use warnings; $|=1; +use Koha::Script; use C4::Context; use C4::Biblio; use Getopt::Long; diff --git a/misc/maintenance/sanitize_records.pl b/misc/maintenance/sanitize_records.pl index 2c8000cd6d..b2547cca73 100755 --- a/misc/maintenance/sanitize_records.pl +++ b/misc/maintenance/sanitize_records.pl @@ -18,6 +18,8 @@ # along with Koha; if not, see . use Modern::Perl; + +use Koha::Script; use C4::Charset qw( SanitizeRecord ); use C4::Context; use DBI; diff --git a/misc/maintenance/search_for_data_inconsistencies.pl b/misc/maintenance/search_for_data_inconsistencies.pl index 525d8c7609..fa5aa20ba3 100755 --- a/misc/maintenance/search_for_data_inconsistencies.pl +++ b/misc/maintenance/search_for_data_inconsistencies.pl @@ -17,6 +17,7 @@ use Modern::Perl; +use Koha::Script; use Koha::Items; use Koha::Biblioitems; use Koha::ItemTypes; diff --git a/misc/maintenance/touch_all_biblios.pl b/misc/maintenance/touch_all_biblios.pl index b6a5addf38..f0630b74fe 100755 --- a/misc/maintenance/touch_all_biblios.pl +++ b/misc/maintenance/touch_all_biblios.pl @@ -28,6 +28,8 @@ BEGIN { # possible modules to use use Getopt::Long; + +use Koha::Script; use C4::Context; use C4::Biblio; use Pod::Usage; diff --git a/misc/maintenance/touch_all_items.pl b/misc/maintenance/touch_all_items.pl index 12dca00070..9b3093ac58 100755 --- a/misc/maintenance/touch_all_items.pl +++ b/misc/maintenance/touch_all_items.pl @@ -28,6 +28,8 @@ BEGIN { # possible modules to use use Getopt::Long; + +use Koha::Script; use C4::Context; use C4::Items; use Pod::Usage; diff --git a/misc/maintenance/update_authorities.pl b/misc/maintenance/update_authorities.pl index 97b6cc39e9..a854f5acdb 100755 --- a/misc/maintenance/update_authorities.pl +++ b/misc/maintenance/update_authorities.pl @@ -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 ); diff --git a/misc/migration_tools/buildCOUNTRY.pl b/misc/migration_tools/buildCOUNTRY.pl index 5cd2da49bf..daca8e5a9c 100755 --- a/misc/migration_tools/buildCOUNTRY.pl +++ b/misc/migration_tools/buildCOUNTRY.pl @@ -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; diff --git a/misc/migration_tools/buildEDITORS.pl b/misc/migration_tools/buildEDITORS.pl index f5e1a71099..37ece96089 100755 --- a/misc/migration_tools/buildEDITORS.pl +++ b/misc/migration_tools/buildEDITORS.pl @@ -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; diff --git a/misc/migration_tools/buildLANG.pl b/misc/migration_tools/buildLANG.pl index 18c27ace7f..5e0a5ab684 100755 --- a/misc/migration_tools/buildLANG.pl +++ b/misc/migration_tools/buildLANG.pl @@ -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; diff --git a/misc/migration_tools/build_oai_sets.pl b/misc/migration_tools/build_oai_sets.pl index 40dfa1b567..a19cc4c025 100755 --- a/misc/migration_tools/build_oai_sets.pl +++ b/misc/migration_tools/build_oai_sets.pl @@ -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; diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index bd80a69b95..5e03ca1d73 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -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; diff --git a/misc/migration_tools/checkNonIndexedBiblios.pl b/misc/migration_tools/checkNonIndexedBiblios.pl index bd47431f0a..d03acbfc7a 100755 --- a/misc/migration_tools/checkNonIndexedBiblios.pl +++ b/misc/migration_tools/checkNonIndexedBiblios.pl @@ -33,6 +33,7 @@ BEGIN { # Koha modules used use MARC::Record; +use Koha::Script; use C4::Context; use Getopt::Long; diff --git a/misc/migration_tools/create_analytical_rel.pl b/misc/migration_tools/create_analytical_rel.pl index a06305f6c9..2de9c23d45 100755 --- a/misc/migration_tools/create_analytical_rel.pl +++ b/misc/migration_tools/create_analytical_rel.pl @@ -9,6 +9,7 @@ BEGIN { eval { require "$FindBin::Bin/../kohalib.pl" }; } +use Koha::Script; use C4::Context; use C4::Biblio; use C4::Items; diff --git a/misc/migration_tools/fix_onloan.pl b/misc/migration_tools/fix_onloan.pl index d6e63af79a..d70c3a5932 100755 --- a/misc/migration_tools/fix_onloan.pl +++ b/misc/migration_tools/fix_onloan.pl @@ -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; diff --git a/misc/migration_tools/import_lexile.pl b/misc/migration_tools/import_lexile.pl index 131db44b12..520c357de9 100755 --- a/misc/migration_tools/import_lexile.pl +++ b/misc/migration_tools/import_lexile.pl @@ -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 ); diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index a79e7a866a..65ccff51b6 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -17,6 +17,7 @@ use Modern::Perl; +use Koha::Script; use C4::Context; use Getopt::Long; use Fcntl qw(:flock); diff --git a/misc/migration_tools/remove_unused_authorities.pl b/misc/migration_tools/remove_unused_authorities.pl index f4e0ecbf2d..bef6cbe4c7 100755 --- a/misc/migration_tools/remove_unused_authorities.pl +++ b/misc/migration_tools/remove_unused_authorities.pl @@ -23,6 +23,7 @@ use strict; use warnings; +use Koha::Script; use C4::Context; use C4::AuthoritiesMarc; use Getopt::Long; diff --git a/misc/migration_tools/switch_marc21_series_info.pl b/misc/migration_tools/switch_marc21_series_info.pl index 54823de9a5..0bad3f2a54 100755 --- a/misc/migration_tools/switch_marc21_series_info.pl +++ b/misc/migration_tools/switch_marc21_series_info.pl @@ -29,6 +29,7 @@ BEGIN { eval { require "$FindBin::Bin/../kohalib.pl" }; } +use Koha::Script; use C4::Biblio; use C4::Context; use Getopt::Long; diff --git a/misc/migration_tools/upgradeitems.pl b/misc/migration_tools/upgradeitems.pl index e3f11d67d5..cc63cd499f 100755 --- a/misc/migration_tools/upgradeitems.pl +++ b/misc/migration_tools/upgradeitems.pl @@ -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; diff --git a/misc/mod_zebraqueue.pl b/misc/mod_zebraqueue.pl index 32fcc31d91..240aad44fa 100755 --- a/misc/mod_zebraqueue.pl +++ b/misc/mod_zebraqueue.pl @@ -23,6 +23,7 @@ use Modern::Perl; use Getopt::Long; use Pod::Usage; +use Koha::Script; use C4::Biblio; my @biblios; diff --git a/misc/recreateIssueStatistics.pl b/misc/recreateIssueStatistics.pl index 6ba83e1e53..2cafb4f444 100755 --- a/misc/recreateIssueStatistics.pl +++ b/misc/recreateIssueStatistics.pl @@ -22,6 +22,8 @@ use strict; use warnings; + +use Koha::Script; use C4::Context; use C4::Items; use Data::Dumper; diff --git a/misc/search_tools/rebuild_elastic_search.pl b/misc/search_tools/rebuild_elastic_search.pl index caa9a3d870..a233cf5d0f 100755 --- a/misc/search_tools/rebuild_elastic_search.pl +++ b/misc/search_tools/rebuild_elastic_search.pl @@ -83,6 +83,7 @@ Full documentation. use autodie; use Getopt::Long; +use Koha::Script; use C4::Context; use Koha::MetadataRecord::Authority; use Koha::BiblioUtils; diff --git a/misc/stage_file.pl b/misc/stage_file.pl index b86f5254d6..b856e3e767 100755 --- a/misc/stage_file.pl +++ b/misc/stage_file.pl @@ -27,6 +27,7 @@ BEGIN { eval { require "$FindBin::Bin/kohalib.pl" }; } +use Koha::Script; use C4::Context; use C4::ImportBatch; use C4::Matcher; diff --git a/t/Koha/Script.t b/t/Koha/Script.t new file mode 100644 index 0000000000..7c758f407a --- /dev/null +++ b/t/Koha/Script.t @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Test::More tests => 3; + +BEGIN { use_ok('Koha::Script') } + +use C4::Context; + +my $userenv = C4::Context->userenv; +is_deeply( + $userenv, + { + 'surname' => 'CLI', + 'id' => undef, + 'flags' => undef, + 'cardnumber' => undef, + 'firstname' => 'CLI', + 'branchname' => undef, + 'branchprinter' => undef, + 'emailaddress' => undef, + 'number' => undef, + 'shibboleth' => undef, + 'branch' => undef + }, + "Context userenv set correctly with no flags" +); + +my $interface = C4::Context->interface; +is( $interface, 'commandline', "Context interface set correctly with no flags" ); + +1; diff --git a/t/Koha/Cron.t b/t/Koha/Script_cron.t similarity index 88% rename from t/Koha/Cron.t rename to t/Koha/Script_cron.t index 05ecd25cee..d73aa82cd0 100644 --- a/t/Koha/Cron.t +++ b/t/Koha/Script_cron.t @@ -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; -- 2.39.5