From f4b3e43a2c2355feb2d2a4b349b75fc6910d801b Mon Sep 17 00:00:00 2001 From: Xavier Guimard Date: Wed, 13 Jun 2018 23:10:40 +0200 Subject: [PATCH] Workaround for ModPerl/Mouse bug (#1452) --- .../lib/Lemonldap/NG/Common/Logger/Log4perl.pm | 1 - .../lib/Lemonldap/NG/Common/Session.pm | 15 ++++++++++++++- .../lib/Lemonldap/NG/Handler/Main/Jail.pm | 16 +++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Logger/Log4perl.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Logger/Log4perl.pm index 72c85d565..5a153b29f 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Logger/Log4perl.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Logger/Log4perl.pm @@ -2,7 +2,6 @@ package Lemonldap::NG::Common::Logger::Log4perl; use strict; use Log::Log4perl; -use Mouse; our $VERSION = '2.0.0'; diff --git a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Session.pm b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Session.pm index 9818311bf..516c7e3d3 100644 --- a/lemonldap-ng-common/lib/Lemonldap/NG/Common/Session.pm +++ b/lemonldap-ng-common/lib/Lemonldap/NG/Common/Session.pm @@ -8,8 +8,21 @@ package Lemonldap::NG::Common::Session; our $VERSION = '2.0.0'; -use Mouse; use Lemonldap::NG::Common::Apache::Session; +BEGIN { + require Mouse; + my $v = $Mouse::VERSION; + $v =~ s/^v//; + if ( $v =~ /^2\.(?:1|2|3|4)/ + and $INC{'Lemonldap/NG/Handler/Apache2/Main.pm'} ) + { + require Moose; + Moose->import(); + } + else { + Mouse->import(); + } +} has 'id' => ( is => 'rw', diff --git a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Jail.pm b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Jail.pm index b463aebc3..2c8463f61 100644 --- a/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Jail.pm +++ b/lemonldap-ng-handler/lib/Lemonldap/NG/Handler/Main/Jail.pm @@ -4,7 +4,21 @@ use strict; use Safe; use Lemonldap::NG::Common::Safelib; #link protected safe Safe object -use Mouse; + +BEGIN { + require Mouse; + my $v = $Mouse::VERSION; + $v =~ s/^v//; + if ( $v =~ /^2\.(?:1|2|3|4)/ + and $INC{'Lemonldap/NG/Handler/Apache2/Main.pm'} ) + { + require Moose; + Moose->import(); + } + else { + Mouse->import(); + } +} has customFunctions => ( is => 'rw', isa => 'Maybe[Str]' );