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 232-238 that, use C<&set_context>. Link Here
232
sub new {
232
sub new {
233
    my $class = shift;
233
    my $class = shift;
234
    my $conf_fname = shift;        # Config file to load
234
    my $conf_fname = shift;        # Config file to load
235
    my $self = {};
236
235
237
    # check that the specified config file exists and is not empty
236
    # check that the specified config file exists and is not empty
238
    undef $conf_fname unless 
237
    undef $conf_fname unless 
Lines 246-263 sub new { Link Here
246
        }
245
        }
247
    }
246
    }
248
247
249
    my $conf_cache = Koha::Caches->get_instance('config');
248
    my $self = Koha::Config->read_from_file($conf_fname);
250
    if ( $conf_cache->cache ) {
251
        $self = $conf_cache->get_from_cache('koha_conf');
252
    }
253
    unless ( $self and %$self ) {
254
        $self = Koha::Config->read_from_file($conf_fname);
255
        if ( $conf_cache->memcached_cache ) {
256
            # FIXME it may be better to use the memcached servers from the config file
257
            # to cache it
258
            $conf_cache->set_in_cache('koha_conf', $self)
259
        }
260
    }
261
    unless ( exists $self->{config} or defined $self->{config} ) {
249
    unless ( exists $self->{config} or defined $self->{config} ) {
262
        warn "The config file ($conf_fname) has not been parsed correctly";
250
        warn "The config file ($conf_fname) has not been parsed correctly";
263
        return;
251
        return;
Lines 366-372 C<C4::Config-E<gt>new> will not return it. Link Here
366
sub _common_config {
354
sub _common_config {
367
	my $var = shift;
355
	my $var = shift;
368
	my $term = shift;
356
	my $term = shift;
369
    return if !defined($context->{$term});
357
    return unless defined $context and defined $context->{$term};
370
       # Presumably $self->{$term} might be
358
       # Presumably $self->{$term} might be
371
       # undefined if the config file given to &new
359
       # undefined if the config file given to &new
372
       # didn't exist, and the caller didn't bother
360
       # didn't exist, and the caller didn't bother
Lines 399-405 with this method. Link Here
399
387
400
=cut
388
=cut
401
389
402
my $syspref_cache = Koha::Caches->get_instance('syspref');
403
my $use_syspref_cache = 1;
390
my $use_syspref_cache = 1;
404
sub preference {
391
sub preference {
405
    my $self = shift;
392
    my $self = shift;
Lines 411-417 sub preference { Link Here
411
    $var = lc $var;
398
    $var = lc $var;
412
399
413
    if ($use_syspref_cache) {
400
    if ($use_syspref_cache) {
414
        $syspref_cache = Koha::Caches->get_instance('syspref') unless $syspref_cache;
401
        my $syspref_cache = Koha::Caches->get_instance('syspref');
415
        my $cached_var = $syspref_cache->get_from_cache("syspref_$var");
402
        my $cached_var = $syspref_cache->get_from_cache("syspref_$var");
416
        return $cached_var if defined $cached_var;
403
        return $cached_var if defined $cached_var;
417
    }
404
    }
Lines 421-426 sub preference { Link Here
421
    my $value = $syspref ? $syspref->value() : undef;
408
    my $value = $syspref ? $syspref->value() : undef;
422
409
423
    if ( $use_syspref_cache ) {
410
    if ( $use_syspref_cache ) {
411
        my $syspref_cache = Koha::Caches->get_instance('syspref');
424
        $syspref_cache->set_in_cache("syspref_$var", $value);
412
        $syspref_cache->set_in_cache("syspref_$var", $value);
425
    }
413
    }
426
    return $value;
414
    return $value;
Lines 489-494 will not be seen by this process. Link Here
489
477
490
sub clear_syspref_cache {
478
sub clear_syspref_cache {
491
    return unless $use_syspref_cache;
479
    return unless $use_syspref_cache;
480
    my $syspref_cache = Koha::Caches->get_instance('syspref');
492
    $syspref_cache->flush_all;
481
    $syspref_cache->flush_all;
493
}
482
}
494
483
Lines 542-547 sub set_preference { Link Here
542
    }
531
    }
543
532
544
    if ( $use_syspref_cache ) {
533
    if ( $use_syspref_cache ) {
534
        my $syspref_cache = Koha::Caches->get_instance('syspref');
545
        $syspref_cache->set_in_cache( "syspref_$variable", $value );
535
        $syspref_cache->set_in_cache( "syspref_$variable", $value );
546
    }
536
    }
547
537
Lines 563-568 sub delete_preference { Link Here
563
553
564
    if ( Koha::Config::SysPrefs->find( $var )->delete ) {
554
    if ( Koha::Config::SysPrefs->find( $var )->delete ) {
565
        if ( $use_syspref_cache ) {
555
        if ( $use_syspref_cache ) {
556
            my $syspref_cache = Koha::Caches->get_instance('syspref');
566
            $syspref_cache->clear_from_cache("syspref_$var");
557
            $syspref_cache->clear_from_cache("syspref_$var");
567
        }
558
        }
568
559
(-)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 442-454 sub install_messages { Link Here
442
    system "$self->{msgfmt} -o $mofile $pofile";
439
    system "$self->{msgfmt} -o $mofile $pofile";
443
440
444
    my $js_locale_data = 'var json_locale_data = {"Koha":' . `$self->{po2json} $js_pofile` . '};';
441
    my $js_locale_data = 'var json_locale_data = {"Koha":' . `$self->{po2json} $js_pofile` . '};';
445
    my $progdir = $self->{context}->config('intrahtdocs') . '/prog';
442
    my $progdir = C4::Context->config('intrahtdocs') . '/prog';
446
    mkdir "$progdir/$self->{lang}/js";
443
    mkdir "$progdir/$self->{lang}/js";
447
    open my $fh, '>', "$progdir/$self->{lang}/js/locale_data.js";
444
    open my $fh, '>', "$progdir/$self->{lang}/js/locale_data.js";
448
    print $fh $js_locale_data;
445
    print $fh $js_locale_data;
449
    close $fh;
446
    close $fh;
450
447
451
    my $opachtdocs = $self->{context}->config('opachtdocs');
448
    my $opachtdocs = C4::Context->config('opachtdocs');
452
    opendir(my $dh, $opachtdocs);
449
    opendir(my $dh, $opachtdocs);
453
    for my $theme ( grep { not /^\.|lib|xslt/ } readdir($dh) ) {
450
    for my $theme ( grep { not /^\.|lib|xslt/ } readdir($dh) ) {
454
        mkdir "$opachtdocs/$theme/$self->{lang}/js";
451
        mkdir "$opachtdocs/$theme/$self->{lang}/js";
455
- 

Return to bug 28276