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

(-)a/C4/Auth_with_ldap.pm (-1 lines)
Lines 50-56 sub ldapserver_error { Link Here
50
}
50
}
51
51
52
use vars qw($mapping @ldaphosts $base $ldapname $ldappassword);
52
use vars qw($mapping @ldaphosts $base $ldapname $ldappassword);
53
my $context = C4::Context->new() 	or die 'C4::Context->new failed';
54
my $ldap = C4::Context->config("ldapserver") or die 'No "ldapserver" in server hash from KOHA_CONF: ' . $ENV{KOHA_CONF};
53
my $ldap = C4::Context->config("ldapserver") or die 'No "ldapserver" in server hash from KOHA_CONF: ' . $ENV{KOHA_CONF};
55
my $prefhost  = $ldap->{hostname}	or die ldapserver_error('hostname');
54
my $prefhost  = $ldap->{hostname}	or die ldapserver_error('hostname');
56
my $base      = $ldap->{base}		or die ldapserver_error('base');
55
my $base      = $ldap->{base}		or die ldapserver_error('base');
(-)a/C4/Context.pm (-16 / +7 lines)
Lines 177-183 that, use C<&set_context>. Link Here
177
sub new {
177
sub new {
178
    my $class = shift;
178
    my $class = shift;
179
    my $conf_fname = shift;        # Config file to load
179
    my $conf_fname = shift;        # Config file to load
180
    my $self = {};
181
180
182
    # check that the specified config file exists and is not empty
181
    # check that the specified config file exists and is not empty
183
    undef $conf_fname unless 
182
    undef $conf_fname unless 
Lines 191-208 sub new { Link Here
191
        }
190
        }
192
    }
191
    }
193
192
194
    my $conf_cache = Koha::Caches->get_instance('config');
193
    my $self = Koha::Config->read_from_file($conf_fname);
195
    if ( $conf_cache->cache ) {
196
        $self = $conf_cache->get_from_cache('koha_conf');
197
    }
198
    unless ( $self and %$self ) {
199
        $self = Koha::Config->read_from_file($conf_fname);
200
        if ( $conf_cache->memcached_cache ) {
201
            # FIXME it may be better to use the memcached servers from the config file
202
            # to cache it
203
            $conf_cache->set_in_cache('koha_conf', $self)
204
        }
205
    }
206
    unless ( exists $self->{config} or defined $self->{config} ) {
194
    unless ( exists $self->{config} or defined $self->{config} ) {
207
        warn "The config file ($conf_fname) has not been parsed correctly";
195
        warn "The config file ($conf_fname) has not been parsed correctly";
208
        return;
196
        return;
Lines 311-317 C<C4::Config-E<gt>new> will not return it. Link Here
311
sub _common_config {
299
sub _common_config {
312
	my $var = shift;
300
	my $var = shift;
313
	my $term = shift;
301
	my $term = shift;
314
    return if !defined($context->{$term});
302
    return unless defined $context and defined $context->{$term};
315
       # Presumably $self->{$term} might be
303
       # Presumably $self->{$term} might be
316
       # undefined if the config file given to &new
304
       # undefined if the config file given to &new
317
       # didn't exist, and the caller didn't bother
305
       # didn't exist, and the caller didn't bother
Lines 344-350 with this method. Link Here
344
332
345
=cut
333
=cut
346
334
347
my $syspref_cache = Koha::Caches->get_instance('syspref');
348
my $use_syspref_cache = 1;
335
my $use_syspref_cache = 1;
349
sub preference {
336
sub preference {
350
    my $self = shift;
337
    my $self = shift;
Lines 356-362 sub preference { Link Here
356
    $var = lc $var;
343
    $var = lc $var;
357
344
358
    if ($use_syspref_cache) {
345
    if ($use_syspref_cache) {
359
        $syspref_cache = Koha::Caches->get_instance('syspref') unless $syspref_cache;
346
        my $syspref_cache = Koha::Caches->get_instance('syspref');
360
        my $cached_var = $syspref_cache->get_from_cache("syspref_$var");
347
        my $cached_var = $syspref_cache->get_from_cache("syspref_$var");
361
        return $cached_var if defined $cached_var;
348
        return $cached_var if defined $cached_var;
362
    }
349
    }
Lines 366-371 sub preference { Link Here
366
    my $value = $syspref ? $syspref->value() : undef;
353
    my $value = $syspref ? $syspref->value() : undef;
367
354
368
    if ( $use_syspref_cache ) {
355
    if ( $use_syspref_cache ) {
356
        my $syspref_cache = Koha::Caches->get_instance('syspref');
369
        $syspref_cache->set_in_cache("syspref_$var", $value);
357
        $syspref_cache->set_in_cache("syspref_$var", $value);
370
    }
358
    }
371
    return $value;
359
    return $value;
Lines 434-439 will not be seen by this process. Link Here
434
422
435
sub clear_syspref_cache {
423
sub clear_syspref_cache {
436
    return unless $use_syspref_cache;
424
    return unless $use_syspref_cache;
425
    my $syspref_cache = Koha::Caches->get_instance('syspref');
437
    $syspref_cache->flush_all;
426
    $syspref_cache->flush_all;
438
}
427
}
439
428
Lines 487-492 sub set_preference { Link Here
487
    }
476
    }
488
477
489
    if ( $use_syspref_cache ) {
478
    if ( $use_syspref_cache ) {
479
        my $syspref_cache = Koha::Caches->get_instance('syspref');
490
        $syspref_cache->set_in_cache( "syspref_$variable", $value );
480
        $syspref_cache->set_in_cache( "syspref_$variable", $value );
491
    }
481
    }
492
482
Lines 508-513 sub delete_preference { Link Here
508
498
509
    if ( Koha::Config::SysPrefs->find( $var )->delete ) {
499
    if ( Koha::Config::SysPrefs->find( $var )->delete ) {
510
        if ( $use_syspref_cache ) {
500
        if ( $use_syspref_cache ) {
501
            my $syspref_cache = Koha::Caches->get_instance('syspref');
511
            $syspref_cache->clear_from_cache("syspref_$var");
502
            $syspref_cache->clear_from_cache("syspref_$var");
512
        }
503
        }
513
504
(-)a/Koha/Cache.pm (-6 / +4 lines)
Lines 45-50 use Module::Load::Conditional qw(can_load); Link Here
45
use Sereal::Encoder;
45
use Sereal::Encoder;
46
use Sereal::Decoder;
46
use Sereal::Decoder;
47
47
48
use C4::Context;
48
use Koha::Cache::Object;
49
use Koha::Cache::Object;
49
use Koha::Config;
50
use Koha::Config;
50
51
Lines 78-89 sub new { Link Here
78
    # Should we continue to support MEMCACHED ENV vars?
79
    # Should we continue to support MEMCACHED ENV vars?
79
    $self->{'namespace'} ||= $ENV{MEMCACHED_NAMESPACE};
80
    $self->{'namespace'} ||= $ENV{MEMCACHED_NAMESPACE};
80
    my @servers = split /,/, $ENV{MEMCACHED_SERVERS} || '';
81
    my @servers = split /,/, $ENV{MEMCACHED_SERVERS} || '';
81
    unless ( $self->{namespace} and @servers ) {
82
    $self->{namespace} ||= C4::Context->config('memcached_namespace') || 'koha';
82
        my $koha_config = Koha::Config->read_from_file( Koha::Config->guess_koha_conf() );
83
    @servers = split /,/, C4::Context->config('memcached_servers') // ''
83
        $self->{namespace} ||= $koha_config->{config}{memcached_namespace} || 'koha';
84
        unless @servers;
84
        @servers = split /,/, $koha_config->{config}{memcached_servers} // ''
85
            unless @servers;
86
    }
87
    $self->{namespace} .= ":$subnamespace:";
85
    $self->{namespace} .= ":$subnamespace:";
88
86
89
    if ( $self->{'default_type'} eq 'memcached'
87
    if ( $self->{'default_type'} eq 'memcached'
(-)a/Koha/Config.pm (-1 / +1 lines)
Lines 30-36 use constant CONFIG_FNAME => "/etc/koha/koha-conf.xml"; Link Here
30
# developers should set the KOHA_CONF environment variable
30
# developers should set the KOHA_CONF environment variable
31
my $INSTALLED_CONFIG_FNAME = '__KOHA_CONF_DIR__/koha-conf.xml';
31
my $INSTALLED_CONFIG_FNAME = '__KOHA_CONF_DIR__/koha-conf.xml';
32
32
33
# Should not be called outside of C4::Context or Koha::Cache
33
# Should not be called outside of C4::Context
34
# use C4::Context->config instead
34
# use C4::Context->config instead
35
sub read_from_file {
35
sub read_from_file {
36
    my ( $class, $file ) = @_;
36
    my ( $class, $file ) = @_;
(-)a/Koha/Database.pm (-13 / +11 lines)
Lines 49-69 sub _new_schema { Link Here
49
49
50
    require Koha::Schema;
50
    require Koha::Schema;
51
51
52
    my $context = C4::Context->new();
52
    my $db_driver = C4::Context::db_scheme2dbi(C4::Context->config('db_scheme'));;
53
53
54
    my $db_driver = $context->{db_driver};
54
    my $db_name   = C4::Context->config("database");
55
55
    my $db_host   = C4::Context->config("hostname");
56
    my $db_name   = $context->config("database");
56
    my $db_port   = C4::Context->config("port") || '';
57
    my $db_host   = $context->config("hostname");
57
    my $db_user   = C4::Context->config("user");
58
    my $db_port   = $context->config("port") || '';
58
    my $db_passwd = C4::Context->config("pass");
59
    my $db_user   = $context->config("user");
59
    my $tls = C4::Context->config("tls");
60
    my $db_passwd = $context->config("pass");
61
    my $tls = $context->config("tls");
62
    my $tls_options;
60
    my $tls_options;
63
    if( $tls && $tls eq 'yes' ) {
61
    if( $tls && $tls eq 'yes' ) {
64
        my $ca = $context->config('ca');
62
        my $ca = C4::Context->config('ca');
65
        my $cert = $context->config('cert');
63
        my $cert = C4::Context->config('cert');
66
        my $key = $context->config('key');
64
        my $key = C4::Context->config('key');
67
        $tls_options = ";mysql_ssl=1;mysql_ssl_client_key=".$key.";mysql_ssl_client_cert=".$cert.";mysql_ssl_ca_file=".$ca;
65
        $tls_options = ";mysql_ssl=1;mysql_ssl_client_key=".$key.";mysql_ssl_client_cert=".$cert.";mysql_ssl_ca_file=".$ca;
68
    }
66
    }
69
67
(-)a/about.pl (-3 / +2 lines)
Lines 221-228 my $warnNoActiveCurrency = (! defined Koha::Acquisition::Currencies->get_active) Link Here
221
221
222
my @xml_config_warnings;
222
my @xml_config_warnings;
223
223
224
my $context = C4::Context->new;
225
226
if (    C4::Context->config('zebra_bib_index_mode')
224
if (    C4::Context->config('zebra_bib_index_mode')
227
    and C4::Context->config('zebra_bib_index_mode') eq 'grs1' )
225
    and C4::Context->config('zebra_bib_index_mode') eq 'grs1' )
228
{
226
{
Lines 235-243 if ( C4::Context->config('zebra_auth_index_mode') Link Here
235
    push @xml_config_warnings, { error => 'zebra_auth_index_mode_is_grs1' };
233
    push @xml_config_warnings, { error => 'zebra_auth_index_mode_is_grs1' };
236
}
234
}
237
235
236
my $authorityserver = C4::Context->zebraconfig('authorityserver');
238
if( (   C4::Context->config('zebra_auth_index_mode')
237
if( (   C4::Context->config('zebra_auth_index_mode')
239
    and C4::Context->config('zebra_auth_index_mode') eq 'dom' )
238
    and C4::Context->config('zebra_auth_index_mode') eq 'dom' )
240
    && ( $context->{'server'}->{'authorityserver'}->{'config'} !~ /zebra-authorities-dom.cfg/ ) )
239
    && ( $authorityserver->{config} !~ /zebra-authorities-dom.cfg/ ) )
241
{
240
{
242
    push @xml_config_warnings, {
241
    push @xml_config_warnings, {
243
        error => 'zebra_auth_index_mode_mismatch_warn'
242
        error => 'zebra_auth_index_mode_mismatch_warn'
(-)a/admin/systempreferences.pl (-2 / +1 lines)
Lines 384-391 output_html_with_http_headers $input, $cookie, $template->output; Link Here
384
# .pref files.
384
# .pref files.
385
385
386
sub get_prefs_from_files {
386
sub get_prefs_from_files {
387
    my $context       = C4::Context->new();
387
    my $path_pref_en  = C4::Context->config('intrahtdocs') .
388
    my $path_pref_en  = $context->config('intrahtdocs') .
389
                        '/prog/en/modules/admin/preferences';
388
                        '/prog/en/modules/admin/preferences';
390
    # Get all .pref file names
389
    # Get all .pref file names
391
    opendir ( my $fh, $path_pref_en );
390
    opendir ( my $fh, $path_pref_en );
(-)a/misc/translator/LangInstaller.pm (-15 / +11 lines)
Lines 34-40 sub set_lang { Link Here
34
    my ($self, $lang) = @_;
34
    my ($self, $lang) = @_;
35
35
36
    $self->{lang} = $lang;
36
    $self->{lang} = $lang;
37
    $self->{po_path_lang} = $self->{context}->config('intrahtdocs') .
37
    $self->{po_path_lang} = C4::Context->config('intrahtdocs') .
38
                            "/prog/$lang/modules/admin/preferences";
38
                            "/prog/$lang/modules/admin/preferences";
39
}
39
}
40
40
Lines 43-51 sub new { Link Here
43
43
44
    my $self                 = { };
44
    my $self                 = { };
45
45
46
    my $context              = C4::Context->new();
46
    $self->{path_pref_en}    = C4::Context->config('intrahtdocs') .
47
    $self->{context}         = $context;
48
    $self->{path_pref_en}    = $context->config('intrahtdocs') .
49
                               '/prog/en/modules/admin/preferences';
47
                               '/prog/en/modules/admin/preferences';
50
    set_lang( $self, $lang ) if $lang;
48
    set_lang( $self, $lang ) if $lang;
51
    $self->{pref_only}       = $pref_only;
49
    $self->{pref_only}       = $pref_only;
Lines 76-92 sub new { Link Here
76
    $self->{langs} = \@langs;
74
    $self->{langs} = \@langs;
77
75
78
    # Map for both interfaces opac/intranet
76
    # Map for both interfaces opac/intranet
79
    my $opachtdocs = $context->config('opachtdocs');
77
    my $opachtdocs = C4::Context->config('opachtdocs');
80
    $self->{interface} = [
78
    $self->{interface} = [
81
        {
79
        {
82
            name   => 'Intranet prog UI',
80
            name   => 'Intranet prog UI',
83
            dir    => $context->config('intrahtdocs') . '/prog',
81
            dir    => C4::Context->config('intrahtdocs') . '/prog',
84
            suffix => '-staff-prog.po',
82
            suffix => '-staff-prog.po',
85
        },
83
        },
86
    ];
84
    ];
87
85
88
    # OPAC themes
86
    # OPAC themes
89
    opendir my $dh, $context->config('opachtdocs');
87
    opendir my $dh, C4::Context->config('opachtdocs');
90
    for my $theme ( grep { not /^\.|lib|xslt/ } readdir($dh) ) {
88
    for my $theme ( grep { not /^\.|lib|xslt/ } readdir($dh) ) {
91
        push @{$self->{interface}}, {
89
        push @{$self->{interface}}, {
92
            name   => "OPAC $theme",
90
            name   => "OPAC $theme",
Lines 98-105 sub new { Link Here
98
    # MARC flavours (hardcoded list)
96
    # MARC flavours (hardcoded list)
99
    for ( "MARC21", "UNIMARC", "NORMARC" ) {
97
    for ( "MARC21", "UNIMARC", "NORMARC" ) {
100
        # search for strings on staff & opac marc files
98
        # search for strings on staff & opac marc files
101
        my $dirs = $context->config('intrahtdocs') . '/prog';
99
        my $dirs = C4::Context->config('intrahtdocs') . '/prog';
102
        opendir $fh, $context->config('opachtdocs');
100
        opendir $fh, C4::Context->config('opachtdocs');
103
        for ( grep { not /^\.|\.\.|lib$|xslt/ } readdir($fh) ) {
101
        for ( grep { not /^\.|\.\.|lib$|xslt/ } readdir($fh) ) {
104
            $dirs .= ' ' . "$opachtdocs/$_";
102
            $dirs .= ' ' . "$opachtdocs/$_";
105
        }
103
        }
Lines 140-146 sub po_filename { Link Here
140
    my $self   = shift;
138
    my $self   = shift;
141
    my $suffix = shift;
139
    my $suffix = shift;
142
140
143
    my $context    = C4::Context->new;
144
    my $trans_path = $Bin . '/po';
141
    my $trans_path = $Bin . '/po';
145
    my $trans_file = "$trans_path/" . $self->{lang} . $suffix;
142
    my $trans_file = "$trans_path/" . $self->{lang} . $suffix;
146
    return $trans_file;
143
    return $trans_file;
Lines 377-384 sub install_installer { Link Here
377
    my $self = shift;
374
    my $self = shift;
378
    return unless ( $self->{installer} );
375
    return unless ( $self->{installer} );
379
376
380
    my $intradir  = $self->{context}->config('intranetdir');
377
    my $intradir  = C4::Context->config('intranetdir');
381
    my $db_scheme = $self->{context}->config('db_scheme');
378
    my $db_scheme = C4::Context->config('db_scheme');
382
    my $langdir  = "$intradir/installer/data/$db_scheme/$self->{lang}";
379
    my $langdir  = "$intradir/installer/data/$db_scheme/$self->{lang}";
383
    if ( -d $langdir ) {
380
    if ( -d $langdir ) {
384
        say "$self->{lang} installer dir $langdir already exists.\nDelete it if you want to recreate it." if $self->{verbose};
381
        say "$self->{lang} installer dir $langdir already exists.\nDelete it if you want to recreate it." if $self->{verbose};
Lines 440-452 sub install_messages { Link Here
440
    system "$self->{msgfmt} -o $mofile $pofile";
437
    system "$self->{msgfmt} -o $mofile $pofile";
441
438
442
    my $js_locale_data = 'var json_locale_data = {"Koha":' . `$self->{po2json} $js_pofile` . '};';
439
    my $js_locale_data = 'var json_locale_data = {"Koha":' . `$self->{po2json} $js_pofile` . '};';
443
    my $progdir = $self->{context}->config('intrahtdocs') . '/prog';
440
    my $progdir = C4::Context->config('intrahtdocs') . '/prog';
444
    mkdir "$progdir/$self->{lang}/js";
441
    mkdir "$progdir/$self->{lang}/js";
445
    open my $fh, '>', "$progdir/$self->{lang}/js/locale_data.js";
442
    open my $fh, '>', "$progdir/$self->{lang}/js/locale_data.js";
446
    print $fh $js_locale_data;
443
    print $fh $js_locale_data;
447
    close $fh;
444
    close $fh;
448
445
449
    my $opachtdocs = $self->{context}->config('opachtdocs');
446
    my $opachtdocs = C4::Context->config('opachtdocs');
450
    opendir(my $dh, $opachtdocs);
447
    opendir(my $dh, $opachtdocs);
451
    for my $theme ( grep { not /^\.|lib|xslt/ } readdir($dh) ) {
448
    for my $theme ( grep { not /^\.|lib|xslt/ } readdir($dh) ) {
452
        mkdir "$opachtdocs/$theme/$self->{lang}/js";
449
        mkdir "$opachtdocs/$theme/$self->{lang}/js";
453
- 

Return to bug 28276