From 6248335a8c6be2b95bde1e61ea90cbd9a3840481 Mon Sep 17 00:00:00 2001 From: Luke Reeves Date: Sun, 12 Jul 2009 10:47:47 -0400 Subject: [PATCH] Work on installation errors with Perl 5.10 --- insipid.cgi | 9 ++++++++- lib/Insipid/Database.pm | 27 ++++++++++++++++----------- lib/Insipid/Schemas.pm | 2 +- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/insipid.cgi b/insipid.cgi index 9ea2a42..d1627f5 100755 --- a/insipid.cgi +++ b/insipid.cgi @@ -18,6 +18,7 @@ # USA # +use Data::Dumper; use warnings; use strict; @@ -42,7 +43,7 @@ if($@) { show_error("Couldn't find the module \"$1\".", "You may want to " . "search CPAN " . "for the module or check the " . - "" . + "" . "Insipid homepage for more information.", $errstr); } elsif ( @@ -50,6 +51,11 @@ if($@) { ($errstr =~ /doesn\'t exist/) || ($errstr =~ /relation \".*\" does not exist/) ) { + print STDERR "Creating database\n"; + + #print STDERR Dumper(\%INC); + #delete $INC{'Insipid/Database.pm'}; + # This means that a database connection was established but the # tables were not found. undef($@); @@ -59,6 +65,7 @@ if($@) { }; if($@) { + $errstr = $@; show_error("Database error", "There was a problem " . "creating the database tables required by Insipid:", $errstr); diff --git a/lib/Insipid/Database.pm b/lib/Insipid/Database.pm index d6c5d90..d7d1275 100755 --- a/lib/Insipid/Database.pm +++ b/lib/Insipid/Database.pm @@ -55,17 +55,9 @@ $dbh = DBI->connect($dsn, $dbuser, $dbpass, { 'RaiseError' => 0}) or die $DBI::e my %options; -my $sql = "select name, value from $tbl_options"; -my $sth = $dbh->prepare($sql); -$sth->execute() or return 1; #die $DBI::errstr; - -while(my $hr = $sth->fetchrow_hashref) { - $options{$hr->{'name'}} = $hr->{'value'}; -} - -if(need_upgrade() eq 1) { - dbupgrade(); -} +#if(need_upgrade() eq 1) { +# dbupgrade(); +#} sub export_options { my ($writer) = (@_); @@ -131,12 +123,25 @@ sub need_upgrade { # Functions sub get_option { + if(keys (%options) == 0) { + my $sql = "select name, value from $tbl_options"; + my $sth = $dbh->prepare($sql); + $sth->execute() or die $DBI::errstr; + + while(my $hr = $sth->fetchrow_hashref) { + $options{$hr->{'name'}} = $hr->{'value'}; + } + $sth->close(); + } + my ($name) = (@_); return $options{$name}; } sub install { my ($sth, @creates); + + print STDERR "Performing database installation.\n"; print "Content-Type: text/html\r\n\r\n"; print "Insipid Installation"; diff --git a/lib/Insipid/Schemas.pm b/lib/Insipid/Schemas.pm index 6f88a3e..6463aaf 100755 --- a/lib/Insipid/Schemas.pm +++ b/lib/Insipid/Schemas.pm @@ -44,7 +44,7 @@ $createPostgres # Insipid will check the database version number on each initialization of # the options table (every hit essentially) and upgrade the tables if there's # any mismatch. -our $version = "0.9.19"; +our $version = "0.9.20"; our $createPostgres = <