View | Details | Raw Unified | Return to bug 37682
Collapse All | Expand All

(-)a/misc/admin/koha-preferences (-6 / +20 lines)
Lines 19-37 Link Here
19
#
19
#
20
20
21
use Modern::Perl;
21
use Modern::Perl;
22
use Koha::Script;
23
use C4::Context;
24
use C4::Log;
25
use Getopt::Long;
22
use Getopt::Long;
26
use Pod::Usage;
23
use Pod::Usage;
27
use YAML::XS;
24
use YAML::XS;
28
25
29
use Koha::Logger;
30
31
use Koha::Database;
26
use Koha::Database;
32
27
33
our %NOT_SET_PREFS = map { $_, 1 } qw( Version );
28
our %NOT_SET_PREFS = map { $_, 1 } qw( Version );
34
29
30
my $lazy_loaded;
31
35
=head1 NAME
32
=head1 NAME
36
33
37
koha-preferences - Get, set, dump and load Koha system preferences
34
koha-preferences - Get, set, dump and load Koha system preferences
Lines 42-47 misc/admin/koha-preferences COMMAND ... Link Here
42
39
43
=cut
40
=cut
44
41
42
sub _lazy_load_modules {
43
    if (!$lazy_loaded){
44
        #NOTE: "use" runs at compile time, so require/import() must be used instead
45
        require Koha::Script;
46
        Koha::Script->import();
47
        require C4::Context;
48
        C4::Context->import();
49
        require C4::Log;
50
        C4::Log->import;
51
        require Koha::Logger;
52
        Koha::Logger->import;
53
        $lazy_loaded = 1;
54
    }
55
}
56
45
sub print_usage {
57
sub print_usage {
46
    my ( $annoyed ) = @_;
58
    my ( $annoyed ) = @_;
47
59
Lines 215-220 my %commands = ( Link Here
215
    },
227
    },
216
    load => sub {
228
    load => sub {
217
        my ( $infile, $force_version );
229
        my ( $infile, $force_version );
230
        _lazy_load_modules();
218
231
219
        GetOptions(
232
        GetOptions(
220
            'i:s' => \$infile,
233
            'i:s' => \$infile,
Lines 246-251 my %commands = ( Link Here
246
    },
259
    },
247
    set => sub {
260
    set => sub {
248
        my ( $preference, $value ) = @_;
261
        my ( $preference, $value ) = @_;
262
        _lazy_load_modules();
249
263
250
        print_usage() unless ( $preference && defined($value) );
264
        print_usage() unless ( $preference && defined($value) );
251
265
Lines 253-258 my %commands = ( Link Here
253
    },
267
    },
254
    clear => sub {
268
    clear => sub {
255
        my ( $preference ) = @_;
269
        my ( $preference ) = @_;
270
        _lazy_load_modules();
256
271
257
        print_usage() unless ( $preference );
272
        print_usage() unless ( $preference );
258
273
259
- 

Return to bug 37682