]> 91.132.146.200 Git - insipid.git/commitdiff
Work on installation errors with Perl 5.10
authorLuke Reeves <luke@neuro-tech.net>
Sun, 12 Jul 2009 14:47:47 +0000 (10:47 -0400)
committerLuke Reeves <luke@neuro-tech.net>
Sun, 12 Jul 2009 14:47:47 +0000 (10:47 -0400)
insipid.cgi
lib/Insipid/Database.pm
lib/Insipid/Schemas.pm

index 9ea2a428a28c2edf6feed503a468bc126e87802b..d1627f5763ed09db94bf73f52f75d460e46ef42d 100755 (executable)
@@ -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 " .
                        "<a href=\"http://search.cpan.org/\">search CPAN</a> " .
                        "for the module or check the " .
-                       "<a href=\"http://www.neuro-tech.net/insipid/\">" .
+                       "<a href=\"https://neuro-tech.net/insipid/\">" .
                        "Insipid</a> 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);
index d6c5d90e42d5b1a2883f289b78f7a146f1c6f014..d7d12755c52685da0c4a8fb3fb29a115db4bd9fc 100755 (executable)
@@ -55,17 +55,9 @@ $dbh = DBI->connect($dsn, $dbuser, $dbpass, { 'RaiseError' => 0}) or die $DBI::e
 \r
 my %options;\r
 \r
-my $sql = "select name, value from $tbl_options";\r
-my $sth = $dbh->prepare($sql);\r
-$sth->execute() or return 1; #die $DBI::errstr;\r
-\r
-while(my $hr = $sth->fetchrow_hashref) {\r
-       $options{$hr->{'name'}} = $hr->{'value'};\r
-}\r
-\r
-if(need_upgrade() eq 1) {\r
-       dbupgrade();\r
-}\r
+#if(need_upgrade() eq 1) {\r
+#      dbupgrade();\r
+#}\r
 \r
 sub export_options {\r
        my ($writer) = (@_);\r
@@ -131,12 +123,25 @@ sub need_upgrade {
 # Functions\r
 \r
 sub get_option {\r
+       if(keys (%options) == 0) {\r
+               my $sql = "select name, value from $tbl_options";\r
+               my $sth = $dbh->prepare($sql);\r
+               $sth->execute() or die $DBI::errstr;\r
+\r
+               while(my $hr = $sth->fetchrow_hashref) {\r
+                       $options{$hr->{'name'}} = $hr->{'value'};\r
+               }\r
+               $sth->close();\r
+       }\r
+\r
        my ($name) = (@_);\r
        return $options{$name};\r
 }\r
 \r
 sub install {\r
        my ($sth, @creates);\r
+\r
+       print STDERR "Performing database installation.\n";\r
        \r
        print "Content-Type: text/html\r\n\r\n";\r
        print "<html><head><title>Insipid Installation</title></head><body>";\r
index 6f88a3e3d2db3889bbe7f94300dcb1e6a8624c84..6463aaf0b40225c8059e7f2789db7989f14720d4 100755 (executable)
@@ -44,7 +44,7 @@ $createPostgres
 # Insipid will check the database version number on each initialization of\r
 # the options table (every hit essentially) and upgrade the tables if there's\r
 # any mismatch.\r
-our $version = "0.9.19";\r
+our $version = "0.9.20";\r
 \r
 our $createPostgres = <<CPOSTGRES;\r
 CREATE TABLE $tbl_authentication (\r