Browse Source

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 <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>
19.05.x
Martin Renvoize 5 years ago
committed by Nick Clemens
parent
commit
d2e189ca1c
  1. 47
      Koha/Script.pm
  2. 1
      misc/admin/koha-preferences
  3. 1
      misc/batchCompareMARCvsFrameworks.pl
  4. 1
      misc/batchDeleteUnusedSubfields.pl
  5. 1
      misc/batchImportMARCWithBiblionumbers.pl
  6. 1
      misc/batchRebuildBiblioTables.pl
  7. 1
      misc/batchRebuildItemsTables.pl
  8. 2
      misc/batchRepairMissingBiblionumbers.pl
  9. 1
      misc/batchdeletebiblios.pl
  10. 1
      misc/check_sysprefs.pl
  11. 1
      misc/commit_file.pl
  12. 2
      misc/cronjobs/advance_notices.pl
  13. 2
      misc/cronjobs/automatic_item_modification_by_age.pl
  14. 2
      misc/cronjobs/automatic_renewals.pl
  15. 2
      misc/cronjobs/batch_anonymise.pl
  16. 2
      misc/cronjobs/build_browser_and_cloud.pl
  17. 2
      misc/cronjobs/cart_to_shelf.pl
  18. 2
      misc/cronjobs/check-url-quick.pl
  19. 4
      misc/cronjobs/check-url.pl
  20. 2
      misc/cronjobs/cleanup_database.pl
  21. 2
      misc/cronjobs/cloud-kw.pl
  22. 2
      misc/cronjobs/create_koc_db.pl
  23. 2
      misc/cronjobs/delete_expired_opac_registrations.pl
  24. 2
      misc/cronjobs/delete_items.pl
  25. 2
      misc/cronjobs/delete_patrons.pl
  26. 2
      misc/cronjobs/delete_records_via_leader.pl
  27. 2
      misc/cronjobs/edi_cron.pl
  28. 2
      misc/cronjobs/fines.pl
  29. 2
      misc/cronjobs/gather_print_notices.pl
  30. 2
      misc/cronjobs/holds/auto_unsuspend_holds.pl
  31. 2
      misc/cronjobs/holds/build_holds_queue.pl
  32. 2
      misc/cronjobs/holds/cancel_expired_holds.pl
  33. 2
      misc/cronjobs/holds/cancel_unfilled_holds.pl
  34. 2
      misc/cronjobs/import_webservice_batch.pl
  35. 2
      misc/cronjobs/j2a.pl
  36. 2
      misc/cronjobs/longoverdue.pl
  37. 2
      misc/cronjobs/membership_expiry.pl
  38. 2
      misc/cronjobs/merge_authorities.pl
  39. 2
      misc/cronjobs/notice_unprocessed_suggestions.pl
  40. 2
      misc/cronjobs/overdue_notices.pl
  41. 2
      misc/cronjobs/process_message_queue.pl
  42. 2
      misc/cronjobs/purge_suggestions.pl
  43. 2
      misc/cronjobs/reconcile_balances.pl
  44. 2
      misc/cronjobs/remove_temporary_edifiles.pl
  45. 2
      misc/cronjobs/rss/rss.pl
  46. 2
      misc/cronjobs/runreport.pl
  47. 2
      misc/cronjobs/serialsUpdate.pl
  48. 2
      misc/cronjobs/share_usage_with_koha_community.pl
  49. 2
      misc/cronjobs/sitemap.pl
  50. 2
      misc/cronjobs/social_data/get_report_social_data.pl
  51. 2
      misc/cronjobs/social_data/update_social_data.pl
  52. 2
      misc/cronjobs/staticfines.pl
  53. 2
      misc/cronjobs/stockrotation.pl
  54. 2
      misc/cronjobs/thirdparty/TalkingTech_itiva_inbound.pl
  55. 2
      misc/cronjobs/thirdparty/TalkingTech_itiva_outbound.pl
  56. 2
      misc/cronjobs/update_totalissues.pl
  57. 1
      misc/devel/create_superlibrarian.pl
  58. 1
      misc/devel/populate_db.pl
  59. 1
      misc/export_borrowers.pl
  60. 1
      misc/export_records.pl
  61. 1
      misc/exportauth.pl
  62. 1
      misc/import_patrons.pl
  63. 1
      misc/link_bibs_to_authorities.pl
  64. 1
      misc/maintenance/UNIMARC_fix_collectiontitle.pl
  65. 1
      misc/maintenance/UNIMARC_sync_date_created_with_marc_biblio.pl
  66. 1
      misc/maintenance/auth_show_hidden_data.pl
  67. 1
      misc/maintenance/borrowers-force-messaging-defaults.pl
  68. 1
      misc/maintenance/cmp_sysprefs.pl
  69. 1
      misc/maintenance/fix_accountlines_date.pl
  70. 1
      misc/maintenance/fix_accountlines_rmdupfines_bug8253.pl
  71. 1
      misc/maintenance/fix_mysql_constraints.pl
  72. 1
      misc/maintenance/fix_tags_weight.pl
  73. 1
      misc/maintenance/make_zebra_dom_cfg_from_record_abs
  74. 2
      misc/maintenance/process_record_through_filter.pl
  75. 1
      misc/maintenance/remove_items_from_biblioitems.pl
  76. 2
      misc/maintenance/sanitize_records.pl
  77. 1
      misc/maintenance/search_for_data_inconsistencies.pl
  78. 2
      misc/maintenance/touch_all_biblios.pl
  79. 2
      misc/maintenance/touch_all_items.pl
  80. 1
      misc/maintenance/update_authorities.pl
  81. 1
      misc/migration_tools/buildCOUNTRY.pl
  82. 1
      misc/migration_tools/buildEDITORS.pl
  83. 1
      misc/migration_tools/buildLANG.pl
  84. 1
      misc/migration_tools/build_oai_sets.pl
  85. 1
      misc/migration_tools/bulkmarcimport.pl
  86. 1
      misc/migration_tools/checkNonIndexedBiblios.pl
  87. 1
      misc/migration_tools/create_analytical_rel.pl
  88. 4
      misc/migration_tools/fix_onloan.pl
  89. 1
      misc/migration_tools/import_lexile.pl
  90. 1
      misc/migration_tools/rebuild_zebra.pl
  91. 1
      misc/migration_tools/remove_unused_authorities.pl
  92. 1
      misc/migration_tools/switch_marc21_series_info.pl
  93. 4
      misc/migration_tools/upgradeitems.pl
  94. 1
      misc/mod_zebraqueue.pl
  95. 2
      misc/recreateIssueStatistics.pl
  96. 1
      misc/search_tools/rebuild_elastic_search.pl
  97. 1
      misc/stage_file.pl
  98. 48
      t/Koha/Script.t
  99. 6
      t/Koha/Script_cron.t

47
Koha/Cron.pm → 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

1
misc/admin/koha-preferences

@ -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;

1
misc/batchCompareMARCvsFrameworks.pl

@ -12,6 +12,7 @@ BEGIN {
}
# Koha modules used
use Koha::Script;
use C4::Context;
use MARC::File::USMARC;
use MARC::Record;

1
misc/batchDeleteUnusedSubfields.pl

@ -11,6 +11,7 @@ BEGIN {
}
# Koha modules used
use Koha::Script;
use MARC::Record;
use C4::Context;
use C4::Biblio;

1
misc/batchImportMARCWithBiblionumbers.pl

@ -12,6 +12,7 @@ BEGIN {
# Koha modules used
use Koha::Script;
use C4::Context;
use C4::Biblio;
use MARC::Record;

1
misc/batchRebuildBiblioTables.pl

@ -13,6 +13,7 @@ BEGIN {
}
# Koha modules used
use Koha::Script;
use MARC::Record;
use C4::Context;
use C4::Biblio;

1
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;

2
misc/batchRepairMissingBiblionumbers.pl

@ -12,7 +12,7 @@ BEGIN {
}
# Koha modules used
use Koha::Script;
use C4::Context;
use C4::Biblio;

1
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);

1
misc/check_sysprefs.pl

@ -10,6 +10,7 @@ use warnings;
use File::Find;
use Koha::Script;
use C4::Context;
@ARGV = qw(.) unless @ARGV;

1
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;

2
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;

2
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;

2
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;

2
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(

2
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;

2
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;

2
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;

4
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;

2
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;

2
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;

2
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);

2
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;

2
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;

2
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;

2
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;

2
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;

2
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;

2
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;

2
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;

2
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;

2
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;

2
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;

2
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);

2
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;

2
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/;

2
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;

2
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;

2
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;

2
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);

2
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;

2
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;

2
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;

2
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

2
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;

2
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;

2
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;

2
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;

2
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;

2
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;

2
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;

2
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;

2
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;

2
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 {

2
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;

2
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;

1
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 );

1
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;

1
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;

1
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;

1
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;

1
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();

1
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;

1
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 {

1
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;

1
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;

1
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;

1
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;

1
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;

1
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;

1
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;

1
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;

1
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;

2
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;

1
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;

2
misc/maintenance/sanitize_records.pl

@ -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;

1
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;

2
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;

2
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;

1
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 );

1
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;

1
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;

1
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;

1
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;

1
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;

1
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;

1
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;

4
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;

1
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 );

1
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);

1
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;

1
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;

4
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;

1
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;

2
misc/recreateIssueStatistics.pl

@ -22,6 +22,8 @@
use strict;
use warnings;
use Koha::Script;
use C4::Context;
use C4::Items;
use Data::Dumper;

1
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;

1
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;

48
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 <http://www.gnu.org/licenses>.
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;

6
t/Koha/Cron.t → 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;
Loading…
Cancel
Save