diff --git a/AppUser.pm b/AppUser.pm index ef68340..d5bb86b 100644 --- a/AppUser.pm +++ b/AppUser.pm @@ -66,13 +66,11 @@ 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 = { - @_, - }; + my $self = $class -> SUPER::new(minimal => 1, # minimal tells SystemModule to skip object checks + @_) + or return undef; - return bless $self, $class; + return $self; } diff --git a/Application.pm b/Application.pm index f4707c9..cf21c14 100644 --- a/Application.pm +++ b/Application.pm @@ -233,7 +233,7 @@ sub run { phpbb => $self -> {"phpbb"}, modules => $self -> {"modules"}, messages => $self -> {"messages"}) - or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Application: Unable to create system object: ".$self -> {"system"} -> {"errstr"}); + or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Application: Unable to create system object: ".$self -> {"system"} -> errstr()); $self -> {"appuser"} -> set_system($self -> {"system"}) if($self -> {"appuser"}); } @@ -244,11 +244,11 @@ sub run { # Obtain the page moduleid, fall back on the default if this fails my $pageblock = $self -> {"block_selector"} -> get_block($self -> {"dbh"}, $self -> {"cgi"}, $self -> {"settings"}, $self -> {"logger"}, $self -> {"session"}) - or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Application: Unable to determine page block: ".$self -> {"block_selector"} -> {"errstr"}); + or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Application: Unable to determine page block: ".$self -> {"block_selector"} -> errstr()); # Obtain an instance of the page module my $pageobj = $self -> {"modules"} -> new_module($pageblock) - or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Application: Unable to load page module $pageblock: ".$self -> {"modules"} -> {"errstr"}); + or $self -> {"logger"} -> die_log($self -> {"cgi"} -> remote_host(), "Application: Unable to load page module $pageblock: ".$self -> {"modules"} -> errstr()); # And call the page generation function of the page module my $content = $pageobj -> page_display(); diff --git a/Auth.pm b/Auth.pm index 006a93e..9164a4e 100644 --- a/Auth.pm +++ b/Auth.pm @@ -55,13 +55,11 @@ use AuthMethods; 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 = { - @_, - }; + my $self = $class -> SUPER::new(minimal => 1, # minimal tells SystemModule to skip object checks + @_) + or return undef; - return bless $self, $class; + return $self; } diff --git a/AuthMethods.pm b/AuthMethods.pm index ba6d955..da6e016 100644 --- a/AuthMethods.pm +++ b/AuthMethods.pm @@ -40,9 +40,8 @@ use Module::Load; sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; - my $self = $class -> SUPER::new(@_); - - return undef if(!$self); + my $self = $class -> SUPER::new(@_) + or return undef; # Ensure that we have objects that we need return SystemModule::set_error("cgi object not set") unless($self -> {"cgi"}); diff --git a/Block.pm b/Block.pm index 42a4a26..09c7611 100644 --- a/Block.pm +++ b/Block.pm @@ -65,8 +65,8 @@ sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = $class -> SUPER::new("logtable" => "", - @_); - return undef if(!$self); + @_) + or return undef; # Set up the logger, if needed (Application usually does this long before the Block constructor # gets called, but even if it has, doing it again won't hurt anything). diff --git a/BlockSelector.pm b/BlockSelector.pm index 930146f..89548da 100644 --- a/BlockSelector.pm +++ b/BlockSelector.pm @@ -29,6 +29,7 @@ package BlockSelector; use strict; +use base qw(SystemModule); # ============================================================================ @@ -43,9 +44,9 @@ use strict; sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; - my $self = { - @_, - }; + my $self = $class -> SUPER::new(minimal => 1, # minimal tells SystemModule to skip object checks + @_) + or return undef; return bless $self, $class; } diff --git a/ConfigMicro.pm b/ConfigMicro.pm index 29e474e..48e9ac8 100644 --- a/ConfigMicro.pm +++ b/ConfigMicro.pm @@ -61,15 +61,10 @@ # allow modifications made to configuration settings to be saved back into the table. package ConfigMicro; -require 5.005; -use DBI; use strict; +use base qw(SystemModule); # Extend SystemModule to get error handling +use DBI; -our $errstr; - -BEGIN { - $errstr = ''; -} # ============================================================================ # Constructor and basic file-based config functions @@ -87,22 +82,19 @@ sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $filename = shift; - - # Object constructors don't get much more minimal than this... - my $self = { "__privdata" => { "modified" => 0 }, - @_, - }; - - my $obj = bless $self, $class; + my $self = $class -> SUPER::new(minimal => 1, # minimal tells SystemModule to skip object checks + "__privdata" => { "modified" => 0 }, + @_) + or return undef; # Return here if we have no filename to load from - return $obj if(!$filename); + return $self if(!$filename); # Otherwise, try to read the file - return $obj if($obj -> read($filename)); + return $self if($self -> read($filename)); # Get here and things have gone wahoonie-shaped - return set_error($obj -> {"errstr"}); + return set_error($self -> {"errstr"}); }