Bug 16067: Remove FastMmap
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 17 Dec 2018 15:45:54 +0000 (12:45 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 4 Dec 2020 14:40:58 +0000 (15:40 +0100)
It is known to be broken, we should remove its implementation

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/Cache.pm
cpanfile
debian/control
t/db_dependent/Cache.t

index 95d0e6b..54fe72f 100644 (file)
@@ -51,7 +51,7 @@ use Koha::Config;
 use base qw(Class::Accessor);
 
 __PACKAGE__->mk_ro_accessors(
-    qw( cache memcached_cache fastmmap_cache memory_cache ));
+    qw( cache memcached_cache ));
 
 our %L1_cache;
 our $L1_encoder = Sereal::Encoder->new;
@@ -94,15 +94,6 @@ sub new {
         $self->{'cache'} = $self->{'memcached_cache'};
     }
 
-    if ( $self->{'default_type'} eq 'fastmmap'
-      && defined( $ENV{GATEWAY_INTERFACE} )
-      && can_load( modules => { 'Cache::FastMmap' => undef } )
-      && _initialize_fastmmap($self)
-      && defined( $self->{'fastmmap_cache'} ) )
-    {
-        $self->{'cache'} = $self->{'fastmmap_cache'};
-    }
-
     $ENV{DEBUG} && carp "Selected caching system: " . ($self->{'cache'} // 'none');
 
     return
@@ -141,33 +132,6 @@ sub _initialize_memcached {
     return $self;
 }
 
-sub _initialize_fastmmap {
-    my ($self) = @_;
-    my ($cache, $share_file);
-
-    # Temporary workaround to catch fatal errors when: C4::Context module
-    # is not loaded beforehand, or Cache::FastMmap init fails for whatever
-    # other reason (e.g. due to permission issues - see Bug 13431)
-    eval {
-        $share_file = join( '-',
-            "/tmp/sharefile-koha", $self->{'namespace'},
-            C4::Context->config('hostname'), C4::Context->config('database') );
-
-        $cache = Cache::FastMmap->new(
-            'share_file'  => $share_file,
-            'expire_time' => $self->{'timeout'},
-            'unlink_on_exit' => 0,
-        );
-    };
-    if ( $@ ) {
-        warn "FastMmap cache initialization failed: $@";
-        return;
-    }
-    return unless defined $cache;
-    $self->{'fastmmap_cache'} = $cache;
-    return $self;
-}
-
 =head2 is_cache_active
 
 Routine that checks whether or not a default caching method is active on this
index a65551f..e757ac6 100644 (file)
--- a/cpanfile
+++ b/cpanfile
@@ -135,7 +135,6 @@ recommends 'Archive::Extract', '0.60';
 recommends 'Archive::Zip', '1.30';
 recommends 'Array::Utils', '0.5';
 recommends 'CGI::Session::Driver::memcached', '0.04';
-recommends 'Cache::FastMmap', '1.34';
 recommends 'DBD::SQLite2', '0.33';
 recommends 'Devel::Cover', '0.89';
 recommends 'File::Copy', '2.08';
index e35743b..a4384d2 100644 (file)
@@ -20,7 +20,6 @@ Build-Depends: libalgorithm-checkdigits-perl,
  libbusiness-isbn-perl,
  libbusiness-issn-perl,
  libbytes-random-secure-perl,
- libcache-fastmmap-perl,
  libcache-memcached-fast-safe-perl,
  libcache-memcached-perl,
  libcgi-compile-perl,
@@ -257,7 +256,6 @@ Depends: libalgorithm-checkdigits-perl,
  libbusiness-isbn-perl,
  libbusiness-issn-perl,
  libbytes-random-secure-perl,
- libcache-fastmmap-perl,
  libcache-memcached-fast-safe-perl,
  libcache-memcached-perl,
  libcgi-compile-perl,
index 3af4f6f..e47393f 100755 (executable)
@@ -284,9 +284,5 @@ END {
         skip "Cache not enabled", 1
           unless ( $cache->is_cache_active() );
         is( $destructorcount, 1, 'Destructor run exactly once' );
-        # cleanup temporary file
-        my $tmp_file = $cache->{ fastmmap_cache }->{ share_file };
-        unlink $tmp_file if defined $tmp_file;
-
     }
 }