From 0d6ff79fc2aae923ab03b68e15d59e0d834b77b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 17 Jul 2020 17:13:03 +0200 Subject: [PATCH] File: Kein deep clone von Strukturen machen die SL::DB::* Objekte enthalten MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Das führt zu Duplizierungen von Singletons, in diesem Fall der Datenbankverbindung die dann beim abbauen kaputtgehen. (cherry picked from commit 9a86234c1a5624573a3f2738cf25b526527796c8) Behebt #358 (redmine). --- SL/File.pm | 3 +-- SL/File/Object.pm | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/SL/File.pm b/SL/File.pm index 830559460..25c6d96c1 100644 --- a/SL/File.pm +++ b/SL/File.pm @@ -4,7 +4,6 @@ use strict; use parent qw(Rose::Object); -use Clone qw(clone); use SL::File::Backend; use SL::File::Object; use SL::DB::History; @@ -78,7 +77,7 @@ sub get_all_versions { for my $version (2..$maxversion) { $main::lxdebug->message(LXDebug->DEBUG2(), "clone for version=".($maxversion-$version+1)); eval { - my $clone = clone($fileobj); + my $clone = $fileobj->clone; $clone->version($maxversion-$version+1); $clone->newest(0); $main::lxdebug->message(LXDebug->DEBUG2(), "clone version=".$clone->version." mtime=". $clone->mtime); diff --git a/SL/File/Object.pm b/SL/File/Object.pm index 7ac8706fc..3aa553d23 100644 --- a/SL/File/Object.pm +++ b/SL/File/Object.pm @@ -124,6 +124,10 @@ sub loaded_db_file { # so, dass wir die nur einmal laden. $_[0]->db_file; } +sub clone { + bless +{ %{ $_[0] } }, __PACKAGE__; +} + sub init_db_file { die 'must always have a db file'; } sub init_loaded { 0 } -- 2.20.1