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

(-)a/C4/Auth.pm (-5 / +33 lines)
Lines 1-3 Link Here
1
package CGI::Session::Serialize::yamlxs;
2
# Proof of concept: CGI::Session::Serialize::yamlxs for CGI::Session:
3
4
use strict;
5
use warnings;
6
7
# hacky hack to trick CGI::Session loader for serializers not to die in its "require":
8
$INC{'CGI/Session/Serialize/yamlxs.pm'} = '1';
9
10
use CGI::Session::ErrorHandler;
11
use YAML::XS ();
12
use Encode ();
13
14
$CGI::Session::Serialize::yamlxs::VERSION = '0.1';
15
@CGI::Session::Serialize::yamlxs::ISA     = ( "CGI::Session::ErrorHandler" );
16
17
sub freeze {
18
    my ($self, $data) = @_;
19
    return Encode::decode_utf8(YAML::XS::Dump($data));
20
}
21
22
sub thaw {
23
    my ($self, $string) = @_;
24
    return (YAML::XS::Load(Encode::encode_utf8($string)))[0];
25
}
26
# ********************************************************************
27
28
29
1
package C4::Auth;
30
package C4::Auth;
2
31
3
# Copyright 2000-2002 Katipo Communications
32
# Copyright 2000-2002 Katipo Communications
Lines 1850-1870 sub _get_session_params { Link Here
1850
    my $storage_method = C4::Context->preference('SessionStorage');
1879
    my $storage_method = C4::Context->preference('SessionStorage');
1851
    if ( $storage_method eq 'mysql' ) {
1880
    if ( $storage_method eq 'mysql' ) {
1852
        my $dbh = C4::Context->dbh;
1881
        my $dbh = C4::Context->dbh;
1853
        return { dsn => "driver:MySQL;id:md5", dsn_args => { Handle => $dbh } };
1882
        return { dsn => "serializer:yamlxs;driver:MySQL;id:md5", dsn_args => { Handle => $dbh } };
1854
    }
1883
    }
1855
    elsif ( $storage_method eq 'Pg' ) {
1884
    elsif ( $storage_method eq 'Pg' ) {
1856
        my $dbh = C4::Context->dbh;
1885
        my $dbh = C4::Context->dbh;
1857
        return { dsn => "driver:PostgreSQL;id:md5", dsn_args => { Handle => $dbh } };
1886
        return { dsn => "serializer:yamlxs;driver:PostgreSQL;id:md5", dsn_args => { Handle => $dbh } };
1858
    }
1887
    }
1859
    elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) {
1888
    elsif ( $storage_method eq 'memcached' && Koha::Caches->get_instance->memcached_cache ) {
1860
        my $memcached = Koha::Caches->get_instance()->memcached_cache;
1889
        my $memcached = Koha::Caches->get_instance()->memcached_cache;
1861
        return { dsn => "driver:memcached;id:md5", dsn_args => { Memcached => $memcached } };
1890
        return { dsn => "serializer:yamlxs;driver:memcached;id:md5", dsn_args => { Memcached => $memcached } };
1862
    }
1891
    }
1863
    else {
1892
    else {
1864
        # catch all defaults to tmp should work on all systems
1893
        # catch all defaults to tmp should work on all systems
1865
        my $dir = C4::Context::temporary_directory;
1894
        my $dir = C4::Context::temporary_directory;
1866
        my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is
1895
        my $instance = C4::Context->config( 'database' ); #actually for packages not exactly the instance name, but generally safer to leave it as it is
1867
        return { dsn => "driver:File;id:md5", dsn_args => { Directory => "$dir/cgisess_$instance" } };
1896
        return { dsn => "serializer:yamlxs;driver:File;id:md5", dsn_args => { Directory => "$dir/cgisess_$instance" } };
1868
    }
1897
    }
1869
}
1898
}
1870
1899
1871
- 

Return to bug 28489