From 6f756e41315273ee8f0e8fee8f5903730ccd3d27 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 9 Aug 2012 16:00:02 +0100 Subject: [PATCH] Can't use superclass constructor; objects may not be avilable. --- AppUser.pm | 7 ++++++- Auth.pm | 8 +++++++- System.pm | 7 ++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/AppUser.pm b/AppUser.pm index e1f3460..ef68340 100644 --- a/AppUser.pm +++ b/AppUser.pm @@ -66,8 +66,13 @@ use constant ADMIN_TYPE => 3; # User type for admin users. sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; + # Note this doesn't use the superclass constructor, as it may be called before + # the objects the superclass checks for are acutally available + my $self = { + @_, + }; - return $class -> SUPER::new(@_); + return bless $self, $class; } diff --git a/Auth.pm b/Auth.pm index 33b5b8f..9b41995 100644 --- a/Auth.pm +++ b/Auth.pm @@ -57,7 +57,13 @@ use AuthMethods; sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; - return $class -> SUPER::new(@_); + # Note this doesn't use the superclass constructor, as it may be called before + # the objects the superclass checks for are acutally available + my $self = { + @_, + }; + + return bless $self, $class; } diff --git a/System.pm b/System.pm index 8ab920a..ce0ebc3 100644 --- a/System.pm +++ b/System.pm @@ -40,8 +40,13 @@ use base qw(SystemModule); sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; + # Note this doesn't use the superclass constructor, as it may be called before + # the objects the superclass checks for are acutally available + my $self = { + @_, + }; - return $class -> SUPER::new(@_); + return bless $self, $class; }