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

(-)a/C4/Context.pm (-4 / +37 lines)
Lines 18-24 package C4::Context; Link Here
18
18
19
use strict;
19
use strict;
20
use warnings;
20
use warnings;
21
use vars qw($VERSION $AUTOLOAD $context @context_stack);
21
use vars qw($VERSION $AUTOLOAD $context @context_stack $servers $memcached $ismemcached);
22
22
23
BEGIN {
23
BEGIN {
24
	if ($ENV{'HTTP_USER_AGENT'})	{
24
	if ($ENV{'HTTP_USER_AGENT'})	{
Lines 78-83 BEGIN { Link Here
78
			$main::SIG{__DIE__} = \&CGI::Carp::confess;
78
			$main::SIG{__DIE__} = \&CGI::Carp::confess;
79
		}
79
		}
80
    }  	# else there is no browser to send fatals to!
80
    }  	# else there is no browser to send fatals to!
81
82
    # memcached stuff
83
    $servers = $ENV{'MEMCACHED_SERVERS'};
84
    if ($servers) {
85
	require Cache::Memcached;
86
	$memcached = Cache::Memcached->new({
87
		      servers => [ $servers ],
88
		      debug   => 0,
89
		      compress_threshold => 10_000,
90
		      namespace => $ENV{'MEMCACHED_NAMESPACE'} || 'koha'
91
		  });
92
	$ismemcached = $memcached->set('ismemcached','1');
93
    }
94
81
	$VERSION = '3.00.00.036';
95
	$VERSION = '3.00.00.036';
82
}
96
}
83
97
Lines 229-234 Returns undef in case of error. Link Here
229
243
230
sub read_config_file {		# Pass argument naming config file to read
244
sub read_config_file {		# Pass argument naming config file to read
231
    my $koha = XMLin(shift, keyattr => ['id'], forcearray => ['listen', 'server', 'serverinfo'], suppressempty => '');
245
    my $koha = XMLin(shift, keyattr => ['id'], forcearray => ['listen', 'server', 'serverinfo'], suppressempty => '');
246
247
    if ($ismemcached) {
248
      $memcached->set('kohaconf',$koha);
249
    }
250
232
    return $koha;			# Return value: ref-to-hash holding the configuration
251
    return $koha;			# Return value: ref-to-hash holding the configuration
233
}
252
}
234
253
Lines 274-279 Allocates a new context. Initializes the context from the specified Link Here
274
file, which defaults to either the file given by the C<$KOHA_CONF>
293
file, which defaults to either the file given by the C<$KOHA_CONF>
275
environment variable, or F</etc/koha/koha-conf.xml>.
294
environment variable, or F</etc/koha/koha-conf.xml>.
276
295
296
It saves the koha-conf.xml values in the declared memcached server(s)
297
if currently available and uses those values until them expire and
298
re-reads them.
299
277
C<&new> does not set this context as the new default context; for
300
C<&new> does not set this context as the new default context; for
278
that, use C<&set_context>.
301
that, use C<&set_context>.
279
302
Lines 308-317 sub new { Link Here
308
            return undef;
331
            return undef;
309
        }
332
        }
310
    }
333
    }
311
        # Load the desired config file.
312
    $self = read_config_file($conf_fname);
313
    $self->{"config_file"} = $conf_fname;
314
    
334
    
335
    if ($ismemcached) {
336
      # retreive from memcached
337
      $self = $memcached->get('kohaconf');
338
      if (not defined $self) {
339
	# not in memcached yet
340
	$self = read_config_file($conf_fname);
341
      }
342
    } else {
343
      # non-memcached env, read from file
344
      $self = read_config_file($conf_fname);
345
    }
346
347
    $self->{"config_file"} = $conf_fname;
315
    warn "read_config_file($conf_fname) returned undef" if !defined($self->{"config"});
348
    warn "read_config_file($conf_fname) returned undef" if !defined($self->{"config"});
316
    return undef if !defined($self->{"config"});
349
    return undef if !defined($self->{"config"});
317
350
(-)a/etc/koha-httpd.conf (-1 / +4 lines)
Lines 16-21 Link Here
16
#  TransferLog __LOG_DIR__/koha-opac-access_log
16
#  TransferLog __LOG_DIR__/koha-opac-access_log
17
   SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
17
   SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
18
   SetEnv PERL5LIB "__PERL_MODULE_DIR__"
18
   SetEnv PERL5LIB "__PERL_MODULE_DIR__"
19
   SetEnv MEMCACHED_SERVERS "__MEMCACHED_SERVERS__"
20
   SetEnv MEMCACHED_NAMESPACE "__MEMCACHED_NAMESPACE__"
19
21
20
   <IfModule mod_gzip.c>
22
   <IfModule mod_gzip.c>
21
     mod_gzip_on yes
23
     mod_gzip_on yes
Lines 106-111 Link Here
106
#  TransferLog __LOG_DIR__/koha-access_log
108
#  TransferLog __LOG_DIR__/koha-access_log
107
   SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
109
   SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
108
   SetEnv PERL5LIB "__PERL_MODULE_DIR__"
110
   SetEnv PERL5LIB "__PERL_MODULE_DIR__"
111
   SetEnv MEMCACHED_SERVERS "__MEMCACHED_SERVERS__"
112
   SetEnv MEMCACHED_NAMESPACE "__MEMCACHED_NAMESPACE__"
109
   Options +FollowSymLinks
113
   Options +FollowSymLinks
110
114
111
   ErrorDocument 400 /cgi-bin/koha/errors/400.pl
115
   ErrorDocument 400 /cgi-bin/koha/errors/400.pl
112
- 

Return to bug 6193