VirtualShelves.pm - expanded SQL for shelf contents, fixes bug of no itemtypes displa...
[koha.git] / C4 / Context.pm
index 6591e62..ca7316b 100644 (file)
@@ -17,6 +17,7 @@ package C4::Context;
 # Suite 330, Boston, MA  02111-1307 USA
 
 use strict;
+use vars qw($VERSION $AUTOLOAD $context @context_stack);
 
 BEGIN {
        if ($ENV{'HTTP_USER_AGENT'})    {
@@ -51,18 +52,14 @@ BEGIN {
                        }       
                CGI::Carp->set_message(\&handle_errors);
     }          # else there is no browser to send fatals to!
+       $VERSION = '3.00.00.036';
 }
 
 use DBI;
 use ZOOM;
 use XML::Simple;
-
 use C4::Boolean;
 
-use vars qw($VERSION $AUTOLOAD $context @context_stack);
-
-$VERSION = '3.00.00.035';
-
 =head1 NAME
 
 C4::Context - Maintain and manipulate the context of a Koha script
@@ -600,13 +597,14 @@ sub _new_dbh
     $db_port = "" unless defined $db_port;
     my $db_user   = $context->config("user");
     my $db_passwd = $context->config("pass");
+    # MJR added or die here, as we can't work without dbh
     my $dbh= DBI->connect("DBI:$db_driver:dbname=$db_name;host=$db_host;port=$db_port",
-         $db_user, $db_passwd);
+         $db_user, $db_passwd) or die $DBI::errstr;
     if ( $db_driver eq 'mysql' ) { 
         # Koha 3.0 is utf-8, so force utf8 communication between mySQL and koha, whatever the mysql default config.
         # this is better than modifying my.cnf (and forcing all communications to be in utf8)
-        $dbh->do("set NAMES 'utf8'") if ($dbh);
         $dbh->{'mysql_enable_utf8'}=1; #enable
+        $dbh->do("set NAMES 'utf8'");
     }
     elsif ( $db_driver eq 'Pg' ) {
            $dbh->do( "set client_encoding = 'UTF8';" );